[Issue 8803] map.filter.array run map delegate an incorrect number of time.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 16 14:31:18 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8803
--- Comment #5 from Peter Alexander <peter.alexander.au at gmail.com> 2012-10-16 14:31:13 PDT ---
(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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list