lazy thoughts
Daniel Keep
daniel.keep.lists at gmail.com
Mon Jan 12 09:12:03 PST 2009
Andrei Alexandrescu wrote:
> [snip]
I like the idea of lazy evaluation; heck, I toyed around with stack
threads so I could write generators.
> 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.
>
> Please let me know what you think!
>
> Andrei
Maybe map should only take invariant data; that way, it's fairly obvious
to the user that you need to pass a block of data that isn't going to be
changed under the map's feet.
-- Daniel
More information about the Digitalmars-d
mailing list