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



--- Comment #7 from deadalnix <deadal...@gmail.com> 2012-10-17 02:47:53 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
> > The problem is that the delegate get executed an impredictable number of 
> > time.
> > Which make side effect extremely hard to handle (I ended up using
> > map.array.filter most of the time in my own codebase) in terms of 
> > side-effect
> > or performance.
> >
> > Additionally, the problem is dependent of the inner implementation of both 
> > map
> > and filter, which should stay unknown for the user.
> 
> I think the real problem here is that your mapping function has side effects.
> The undocumented intention of map is that the mapping function is pure. Using
> it to produce side-effects on the function call is not the intended use of map
> (just like having side effects in the comparison function in a sort would be a
> bad idea).
> 
> Other than the incorrect documentation, I don't think there is a bug here.

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).

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

Reply via email to