http://d.puremagic.com/issues/show_bug.cgi?id=8803



--- Comment #8 from Peter Alexander <peter.alexander...@gmail.com> 2012-10-17 
04:54:17 PDT ---
(In reply to comment #7)
> Well, I do think many valid uses include impure functions, even in sort. For
> instance for benchmarking purpose, for educational purpose, for caching.
> 
> More importantly, pure function isn't enough. A pure function can return 2
> different objects. Even if the object's content will be the same, its identity
> will not, which is a problem in many cases (the example above is simplified, 
> in
> my case that was the issue).

I think this issue boils down to this: you are expecting something from map,
which is does not advertise to do (any more). There is no bug.

You could change this to an enhancement request, because you are asking for an
additional feature.

Note that if you do add caching for 'front', you still have the same problem if
you try to use indexing. e.g.

auto xs = [1, 2, 3];
auto m = xs.map!(fun)();
auto ref a = m[1], b = m[1];

The only way this could guarantee to apply fun once is if it caches the entire
range, which is totally impractical.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to