Proposal idea - generators

Howard Lovatt howard.lovatt at
Wed Apr 1 16:13:08 PDT 2009

My reading of the Scala Language Specification, page 83, is that the  
for loop is translated into a map call (or similar). Therefore whether  
this is lazy or not is an implementation detail. So I think it is  
valid to eagerly evaluate the loop and store the results in a hash  
map. After all, the current Java for loop evaluates eagerly.

Functional languages like Mathematica, which are extensively used in  
Science and maths, eagerly evalate and store the results. In fact this  
is a common array generation means.

   -- Howard

On 02/04/2009, at 8:56 AM, Neal Gafter <neal at> wrote:

> On Wed, Apr 1, 2009 at 2:41 PM, Neal Gafter <neal at> wrote:
>> On Wed, Apr 1, 2009 at 1:34 PM, Howard Lovatt  
>> <howard.lovatt at> wrote:
>>> Note I am not
>>> proposing, and I don't believe the original poster was either, a
>>> continuation style yield. More a Scala and other non-lazy functional
>>> language style were the results are stored in a Map and the Map is
>>> returned, i.e. like applying (mapping) a function to each element  
>>> of a
>>> list but with more control (in particular break and continue
>>> functionality).
>> Scala's comprehensions using their standard libraries are lazy.  See,
>> for example, Iterator.range.  C#'s iterator methods are translated
>> into a state machine (i.e. coroutines) and are inherently lazy.  F#
>> and OCaml are the most widely used non-lazy functional languages, but
>> their comprehensions are lazy too.  So I'm not sure what you're  
>> saying
>> your proposal is comparable to.
> I may be wrong about OCaml's generators.
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit
> ______________________________________________________________________

More information about the coin-dev mailing list