bearophile <bearophileh...@lycos.com> wrote:

class or instance immutability is necessary to ensure determinism in a
concurrent program, as otherwise a mutable alias can be used to
concurrently modify the object.

That's the price of being a systems language - it is possible to subvert
the type system. However, we also have per-type immutability, which is
harder to circumvent (though still possible). I thought the latter also
existed in D at the time, though I know not for sure.


the recipient of an immutable reference may still need to make a
defensive copy.

This is bullcrap. Yes, one could break the type system as explained, but
if you're going to assume programmers will do that, you might as well
write assembly and only use ad-hoc described types.


At page 6 it explains their approach to pure functions:

Languages that meet our requirements (ยง 4) make verification of purity easy. The condition is simple: If all parameters to a method (including the implicit this parameter) are statically declared to be of an immutable type, then the method is pure. [...] In our approach, purity is part of the contract of a method: we can verify that a method is pure simply by examining its type signature.


(This is possible because there is no mutable global state.)

So it is basically exactly like D, only no mutable global state?


--
Simen

Reply via email to