lazy thoughts

Robert Fraser fraserofthenight at gmail.com
Mon Jan 12 09:41:52 PST 2009


Sergey Gromov wrote:
> Mon, 12 Jan 2009 09:05:18 -0800, Andrei Alexandrescu wrote:
> 
>> Also, lazy evaluation has the risk of getting confusing as there's a lot 
>> of escaping. Consider:
>>
>> int[] arr = [ 1, 2, 3, 4 ];
>> auto squares = map!("a * a")(arr);
>> arr[] = [ 5, 6, 7, 8 ];
>>
>> Now iterating squares will see different numbers than the original ones.
> 
> This part bothers me.  Though it's hard to tell how much danger it would
> impose in practice.

I could also see it being useful in some situations. But, yes, it is 
unexpected.



More information about the Digitalmars-d mailing list