On Fri, 21 Mar 2014 14:18:05 -0400, Walter Bright
<newshou...@digitalmars.com> wrote:
On 3/21/2014 12:59 AM, monarch_dodra wrote:
Ok. That's a fair point. So in that case, our function is pointing at
"data",
and is allowed to mutate it, and observe its state.
Now, if *another* piece of code is doing the same thing at the same time
(potentially mutating "data", does that still violate purity?
A mutex essentially reads and writes a global flag, which other
functions can also read and write.
That makes it NOT pure.
No, that's not the case. A mutex does not write a global flag, it writes a
shared flag. And the flag is passed into it.
I still think straight locking and unlocking of mutexes should be pure,
because of the exclusive nature of the data protected by them.
-Steve