On Friday, 21 March 2014 at 02:00:11 UTC, Walter Bright wrote:
On 3/20/2014 6:40 PM, Steven Schveighoffer wrote:
How do they affect global state?

Mutexes implicitly share state. It's the reason they exist. They can't be pure, because pure functions don't share state.

Locking a monitor is also a mutating operation and yet I believe you can have const synchronized methods. They live somewhat outside the normal type system. I don't see any point in having pure class methods, but what about:

pure int add(T)(const(T) a, const(T) b) {
    return a + b;
}

Where the variables above are instances of a synchronized class? The operation would implicitly lock their monitors to perform the addition.

Reply via email to