From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,f92fbb4a0420dd57 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,f92fbb4a0420dd57 X-Google-Attributes: gid103376,public 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 Message-ID: <4jlmn5$h1k@Nntp1.mcs.net>#1/1 X-Deja-AN: 145093110 references: content-type: Text/Plain; charset=US-ASCII organization: Fen Software, Inc. mime-version: 1.0 newsgroups: comp.lang.ada,comp.lang.c++ Date: 1996-03-31T00:00:00+00:00 List-Id: In article , 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.