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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f43e6,a9ec16e88ef2b543 X-Google-Attributes: gidf43e6,public X-Google-Thread: fac41,a9ec16e88ef2b543 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,a7b18e7570ac8dc3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-14 14:17:51 PST Path: bga.com!news.sprintlink.net!sundog.tiac.net!usenet.elf.com!news2.near.net!MathWorks.Com!panix!zip.eecs.umich.edu!newsxfer.itd.umich.edu!uunet!timbuk.cray.com!equalizer!network.ucsd.edu!mbk From: mbk@inls1.ucsd.edu (Matt Kennel) Newsgroups: comp.software-eng,comp.lang.eiffel,comp.lang.ada Subject: Re: Eiffel gripe (was Ada vs. Eiffel) Followup-To: comp.software-eng,comp.lang.eiffel,comp.lang.ada Date: 14 Sep 1994 02:07:36 GMT Organization: Institute For Nonlinear Science, UCSD Message-ID: <355lt8$1vi@network.ucsd.edu> References: <351men$ruo@gnat.cs.nyu.edu> NNTP-Posting-Host: lyapunov.ucsd.edu X-Newsreader: TIN [version 1.1 PL8] Xref: bga.com comp.software-eng:7501 comp.lang.eiffel:1983 comp.lang.ada:5901 Date: 1994-09-14T02:07:36+00:00 List-Id: Robert Dewar (dewar@cs.nyu.edu) wrote: : If we are on the subject of loop syntax, how about the loop kit for SETL : that I (probably in a fit of over-complex thinking) designed: : init : step : while : loop : ... : end : within the loop there was both a quit and a continue for early exits to : either outside the loop or the next iteration (actually to the step code) : Well you sure could do anything with that. As in C, one of the powerful : uses of general iteration schemes like this is in connection with macros, : which allow you to do lots of nice things, but are so open to major : abuse that in the final analysis I prefer Ada's approach of excluding : macros as a first class capability (SETL *did* have a powerful macro : facility as well). What about Sather's iters? That is the nicest way that I've seen to do loops. All the "init", "step" and "exit" critera are user-programmable in 'iters', which are written like class routines. For example, loop x := collection.elt!; -- each 'x' is an element of the collection. end; "elt!" is an iter in the class of object 'collection'. It initializes internal variables for a loop, and on each iteration through the loop written here, some iter code is called which returns successive elements of the container object. When the iter decides that the loop is done (runs out of elements, e.g.) the actual outer loop is exited itself. If it's an array based structure, then the code for "elt!" would be simple. If it were a linked list, it would be more complicated, or a tree more complicated still. Nevertheless you would write the loop just as above. Each kind of loop structure that you want is user programmable, attached to appropriate classes and completely safe. It's nicer than having to use inefficient 'iterator' objects, one for each different kind of iteration that you want. -- -Matt Kennel mbk@inls1.ucsd.edu -Institute for Nonlinear Science, University of California, San Diego -*** AD: Archive for nonlinear dynamics papers & programs: FTP to -*** lyapunov.ucsd.edu, username "anonymous".