comp.lang.ada
 help / color / mirror / Atom feed
From: mbk@inls1.ucsd.edu (Matt Kennel)
Subject: Re: Eiffel gripe (was Ada vs. Eiffel)
Date: 14 Sep 1994 02:07:36 GMT
Date: 1994-09-14T02:07:36+00:00	[thread overview]
Message-ID: <355lt8$1vi@network.ucsd.edu> (raw)
In-Reply-To: 351men$ruo@gnat.cs.nyu.edu

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 <stuff to do before loop.
: doing <stuff to do at start of each loop>
: step <stuff to do at end of each loop>
: while <condition to test at start of loop>
: 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".



  reply	other threads:[~1994-09-14  2:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <DERWAY.94Aug23180251@alumni.ndc.com>
     [not found] ` <DERWAY.94Aug31133058@alumni.ndc.com>
     [not found]   ` <1994Sep1.094653@lglsun.epfl.ch>
     [not found]     ` <34473c$ru5@info2.rus.uni-stuttgart.de>
     [not found]       ` <344isl$brd@Starbase.NeoSoft.COM>
     [not found]         ` <3450li$t04@disuns2.epfl.ch>
1994-09-06 13:41           ` Ada vs. Eiffel Graham Perkins
     [not found]           ` <1994Sep4.100449.205@aldur.demon.co.uk>
     [not found]             ` <34e4rgINNqdg@ephor.tusc.com.au>
1994-09-12  9:35               ` Eiffel gripe (was Ada vs. Eiffel) Matthias Ernst
1994-09-12 13:52                 ` Robert Dewar
1994-09-14  2:07                   ` Matt Kennel [this message]
1994-09-14 15:37                     ` Jacob Gore
replies disabled

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