September 17, 2010 [phobos] Fixing Map | ||||
---|---|---|---|---|
| ||||
I'm thinking about improving/fixing std.algorithm.Map. Two things I want to bounce off other Phobos devs: 1. Should we just dump the cache? I can't think of any other reasonable way to fix http://d.puremagic.com/issues/show_bug.cgi?id=4798 . In real world use cases the mapping function is cheap, and if not people will probably just call array() to do it eagerly. 2. Should Map return by ref if possible? This would enable idioms like this: struct S { uint a, b, c; } ref uint getA(ref S s) { return s.a; } auto sArray = new S[42]; sort(map!getA(sArray)); |
January 02, 2011 [phobos] Fixing Map | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | On 9/17/10 10:00 PM, David Simcha wrote: > I'm thinking about improving/fixing std.algorithm.Map. Two things I want to bounce off other Phobos devs: > > 1. Should we just dump the cache? I can't think of any other reasonable way to fix http://d.puremagic.com/issues/show_bug.cgi?id=4798 . In real world use cases the mapping function is cheap, and if not people will probably just call array() to do it eagerly. Fortunately I dumped it already. It's caused more trouble than good. > 2. Should Map return by ref if possible? This would enable idioms like this: > > struct S { > uint a, b, c; > } > > ref uint getA(ref S s) { return s.a; } > > auto sArray = new S[42]; > sort(map!getA(sArray)); Good question. I think that's worth pursuing. Andrei |
Copyright © 1999-2021 by the D Language Foundation