[net.lang] Generators & Iterators / Re: Loop Indexing

phipps@fortune.UUCP (Clay Phipps) (01/17/84)

-------------------------------

I can think of four languages that support generators or iterators
(in the sense of function-like things that produce values for loops):

o  CLU     -- Barbara Liskov, Alan Snyder, Russell Atkinson, Craig Schaffert
              @ MIT
o  Alphard -- Bill Wulf & Mary Shaw @ Carnegie-Mellon; Ralph London @ USC
o  Euclid  -- Butler Lampson, Jim Horning, Ralph London, Jim Mitchell,
              Gerald Popek @ all over North America
o  Icon    -- Ralph Griswold, Dave Hanson, Tim Korb, Walt Hansen @ U of Arizona

One of the Alphard papers pointed out that related constructs appeared in

o  IPL-V   (called "generators")
o  LISP    (obtained by using a "mapping function")

I think that Smalltalk may support them, also.

Ada doesn't have generators or even a repetition statement 
that allows the compiler to choose the ordering of loop variable values.
So much for the latest in programming languages technology from DoD.

One shouldn't forget APL, where the custom is to perform actions
on entire arrays all at once, at least abstractly.  On serial machines,
this means that the APL processor is choosing its own order for operations.
Give some thought to the percentage of loops in conventional programming
languages that are used solely to access array elements, and it will
become clear how looping constructs are of little interest to APL people.
In combination with recursion, loops in the usual sense are rarely needed
(or never needed, if you are a purist), except maybe for processing
input provided interactively by humans.

I could provide more detail about generators in the languages named above,
but all the institutions responsible for them are either on USENET,
or have access to it thru ARPANET, and they can probably explain the
fine points of their languages' features with greater accuracy than I can.

-- Clay Phipps

-- 
   {allegra,amd70,cbosgd,dsd,floyd,harpo,hollywood,hpda,ihnp4,
    magic,megatest,nsc,oliveb,sri-unix,twg,varian,VisiA,wdl1}
   !fortune!phipps

barmar@mit-eddie.UUCP (Barry Margolin) (01/20/84)

I don't know about some of the other languages, but iterators in CLU
don't provide a mechanism for the compiler to optimize the order in
which elements are processed.  The iterator procedure yields the items
in a well-defined order.

The place to look for examples of this kind of stuff is in languages
designed for multi-processor systems.  I also heard about an
APL-machine, i.e. a minicomputer with microcode designed for running
APL, with an array processor so that it could process arrays
efficiently.
-- 
			Barry Margolin
			ARPA: barmar@MIT-Multics
			UUCP: ..!genrad!mit-eddie!barmar