Pure functions in D
Steven Schveighoffer
schveiguy at yahoo.com
Mon Sep 22 15:12:58 PDT 2008
"bearophile" wrote
> Walter:
>>Parameters to a pure function can be mutable, but calls cannot be cached
>>or executed asynchronously if the arguments contain any references to
>>mutable data.<
>
> I don't understand how can such function be pure.
It can't be. I think Walter made a mistake there. Otherwise, you could
pass data that another thread changes while in the middle of using it.
Maybe he meant that a pure function can *return* mutable data? Then 'new'
could be considered pure?
Another possibility is that Walter is assuming the shared/unshared paradigm
is in place.
Another possibility is that pure functions that accept mutable parameters
can only be called from other pure functions, therefore you are guaranteed
that the data is not being used in any other thread.
Who knows what he was thinking ;) But the current article statement is
definitely wrong without clarification.
-Steve
More information about the Digitalmars-d
mailing list