I thought pure functions can't modify their parameters (along with any other non-local variables). if the pure function can't modify anything non-local, why should it care whether it's getting called from a shared context or not?
On Tue, Oct 25, 2011 at 9:31 PM, Jonathan M Davis <[email protected]> wrote: > On Tuesday, October 25, 2011 03:13 Gor Gyolchanyan wrote: >> Pure functions don't need synchronization. Pure functions should not >> be a subject to shared-ness. > > Why? All it means when a function is pure is that it can't access any static > or module-level variables which can ever be mutated over the course of the > program. It has nothing to do with shared or synchronization. True, there are > circumstances under which calls to a pure function can be optimized out (e.g. > when all of its parameters are immutable or implicitly convertible to > immutable), but there's nothing stopping you from creating pure functions > which take or return shared variables, and those functions could be called > just like any other function which takes or returns shared variables. > > - Jonathan M Davis >
