Map Lambda with Side-Effects
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 13 02:30:04 PST 2015
On Tuesday, 13 January 2015 at 10:21:12 UTC, Tobias Pankrath
wrote:
> On Tuesday, 13 January 2015 at 10:06:26 UTC, bearophile wrote:
>> Nordlöw:
>>
>>> Has there been any discussions on
>>> making map require pure functions now that we have each?
>>
>> Perhaps I'd like Phobos map and filter to be annotated with
>> "pure" and to have a template constraint that requires their
>> mapping/filtering functions to be strongly pure.
>>
>> Bye,
>> bearophile
>
> Please not.
It should be obviously documented that the number of applications
of the function is not limited to once-per-element and that
evaluation doesn't necessarily happen in-order. I forget and am
re-reminded of this once every few months, despite how central it
is to ranges in general.
It can still be useful to use impure functions with it though, as
long as you consider what is actually going on.
More information about the Digitalmars-d-learn
mailing list