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: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user) Date: 1996/04/01 Message-ID: #1/1 X-Deja-AN: 145287504 references: organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada,comp.lang.c++ Date: 1996-04-01T00:00:00+00:00 List-Id: In article , I said: > The choice was between Ada and a shell script...I chose Ada. In article <4jlmn5$h1k@Nntp1.mcs.net> mikey@mcs.com (Mike Young) writes: > I don't know about that, Robert. The equivalent shell script would be... No, that would NOT be the equivalent shell script. Yes, that is similar to the approach I would have taken with a shell script, but the main difference is that the shell script would invoke a program once for each file, while the Ada approach allowed me to invoke a subprogram WITHIN a program once for each file name. Now the actual tasks the tools were doing were such that having a single program run 1000 times with state passed through (other) files would have resulted in O(N squared) preformance as the state files to be read in each time got larger and larger. Another path I considered was to use a script to catenate all files together--in a pipe, not a file--then write a separate program to take the pipe as input. In that case I lose the advantages of having the file name as "out of band" information. I'd have to prepend a structured comment to each file before piping it, and on the other end, look for the structured comments and process them. Also, I could have used a DBMS, but that would have required different DDL and SQL for each of several tools, where with the all Ada approach much of the code could be shared. So after doing a quick analysis, writing a file iterator--which took about two hours to write and debug--was by far the best solution. I posted the code because others may find it useful as well, even in cases where the "simple" shell script would work. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...