comp.lang.ada
 help / color / mirror / Atom feed
From: mikey@mcs.com (Mike Young)
Subject: Re: Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user)
Date: 1996/03/31
Date: 1996-03-31T00:00:00+00:00	[thread overview]
Message-ID: <4jlmn5$h1k@Nntp1.mcs.net> (raw)
In-Reply-To: EACHUS.96Mar29191146@spectre.mitre.org

In article <EACHUS.96Mar29191146@spectre.mitre.org>, eachus@spectre.mitre.org> 
says...
>some tools over the code.  The choice was between Ada and a shell
>script...I chose Ada:
>
>generic
>  with procedure To_Do(File: in String);
>procedure Iterate_Files(Pattern: in String := "*";
>                        Directory: in String := "");
>-- This generic iterates over all files in a directory matching Pattern and
>-- calls To_Do once for each such directory entry.  If a file has several
>-- links in the directory To_Do will be called once for each.

=========
I don't know about that, Robert. The equivalent shell script would be:

#---- iterateFiles
fileop=$1;shift
for file in $*; do $fileop $file; done

You would call it thusly:

  iterateFiles 'head -n 3' *.ada >header.comments

or, directly, without a script:
  for file in *.ada; do head -n 3 $file; done >header.comments

or, in Windows NT or 95:
  for %i in (*.ada) do gnatchop -s -w %i

You are not restricted to procedures in that same program, all system utilities 
are directly available, you don't need to rebuild to add new features, and you 
need not have bothered with your 50 lines of code. All are big wins, IMO. You 
can always write small, easy to maintain, helper programs if available 
utilities don't do what you need.

>
>
>   Two observations.  First, the generic procedure approach is
>certainly right for this case.  Second, the VADS run-time provided a
>call for freeing A_Strings, but not for find_files.find_file_rec, so I

===========
Hmmm.

Mike.





  reply	other threads:[~1996-03-31  0:00 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-27  0:00 some questions re. Ada/GNAT from a C++/GCC user Bill Newman
1996-03-27  0:00 ` Robert Dewar
1996-03-28  0:00   ` Brian Rogoff
1996-03-29  0:00     ` John G. Volan
1996-03-30  0:00       ` Mike Young
1996-03-30  0:00         ` Ted Dennison
1996-03-31  0:00           ` Mike Young
1996-03-30  0:00       ` Robert A Duff
1996-03-31  0:00         ` John G. Volan
1996-03-31  0:00           ` Mike Young
1996-04-02  0:00             ` Glenn H. Porter
1996-04-02  0:00               ` Jonas Nygren
1996-04-02  0:00               ` Robert Dewar
1996-04-03  0:00               ` Geert Bosch
1996-04-03  0:00                 ` Robert Dewar
1996-04-01  0:00           ` Bruce.Conroy
1996-04-01  0:00           ` Robert A Duff
1996-04-03  0:00             ` Scott Leschke
1996-04-04  0:00               ` AdaWorks
1996-03-31  0:00         ` Robert Dewar
1996-04-01  0:00           ` Norman H. Cohen
1996-04-01  0:00       ` Norman H. Cohen
1996-04-01  0:00         ` Mike Young
1996-04-02  0:00           ` Robert Dewar
1996-04-02  0:00           ` David Shochat
1996-04-02  0:00             ` Mike Young
1996-04-02  0:00           ` Norman H. Cohen
1996-04-01  0:00         ` Robert A Duff
1996-04-01  0:00           ` Mike Young
1996-04-02  0:00             ` Norman H. Cohen
1996-04-02  0:00             ` Robert A Duff
1996-03-28  0:00   ` Norman H. Cohen
1996-03-28  0:00 ` Scott Leschke
1996-03-29  0:00   ` Robert A Duff
1996-03-30  0:00     ` Richard Pitre
1996-03-30  0:00       ` Robert A Duff
1996-03-31  0:00         ` AdaWorks
1996-04-01  0:00           ` Robert A Duff
1996-04-01  0:00             ` AdaWorks
1996-04-01  0:00               ` Mike Young
1996-04-02  0:00                 ` AdaWorks
1996-04-02  0:00                 ` Robert Dewar
1996-04-01  0:00             ` Norman H. Cohen
1996-04-01  0:00             ` Ken Garlington
1996-04-01  0:00               ` Robert A Duff
1996-04-02  0:00                 ` Tucker Taft
1996-04-02  0:00                   ` Felaco
1996-04-02  0:00                     ` Robert Dewar
1996-04-03  0:00                     ` Mark A Biggar
1996-04-02  0:00                 ` Ken Garlington
1996-04-02  0:00                   ` Robert A Duff
1996-04-02  0:00                     ` Ken Garlington
1996-04-02  0:00                       ` Robert A Duff
1996-04-03  0:00                         ` David Emery
1996-04-03  0:00                         ` Ken Garlington
1996-04-09  0:00                           ` Matt Kennel
1996-04-01  0:00         ` Richard A. O'Keefe
1996-04-01  0:00           ` Robert A Duff
1996-04-01  0:00         ` Robert Dewar
1996-04-02  0:00       ` Robert I. Eachus
1996-03-29  0:00   ` Robert I. Eachus
1996-03-29  0:00   ` Bill Newman
1996-03-28  0:00 ` Ted Dennison
1996-03-29  0:00   ` Adam Beneschan
1996-03-29  0:00 ` Robert A Duff
1996-03-29  0:00   ` Brian Rogoff
1996-04-01  0:00     ` Mark A Biggar
1996-04-01  0:00       ` Robert A Duff
1996-03-30  0:00   ` Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user) Robert I. Eachus
1996-03-31  0:00     ` Mike Young [this message]
1996-03-31  0:00       ` Fergus Henderson
1996-04-01  0:00   ` Robert I. Eachus
     [not found]   ` <4jlj79$h1k@Nntp1.mcs.net>
1996-04-01  0:00     ` some questions re. Ada/GNAT from a C++/GCC user Robert A Duff
1996-04-02  0:00       ` Kevin Cline
1996-04-02  0:00         ` Robert A Duff
1996-04-04  0:00   ` Jon S Anthony
1996-03-30  0:00 ` Simon Wright
1996-04-01  0:00 ` Laurent Guerby
1996-04-01  0:00   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox