Proposal idea - generators
howard.lovatt at gmail.com
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.
On 02/04/2009, at 8:56 AM, Neal Gafter <neal at gafter.com> wrote:
> On Wed, Apr 1, 2009 at 2:41 PM, Neal Gafter <neal at gafter.com> wrote:
>> On Wed, Apr 1, 2009 at 1:34 PM, Howard Lovatt
>> <howard.lovatt at iee.org> 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
>> 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
>> 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 http://www.messagelabs.com/email
More information about the coin-dev