thoughts on immutability in D

Jonathan M Davis jmdavisProg at gmx.com
Sun Sep 25 23:32:16 PDT 2011


On Monday, September 26, 2011 08:14:31 Rainer Schuetze wrote:
> Which finally brings us back to the original question: What does
> immutable guarantee in the face of non-pure property getter functions?

immutable guarantees that when an object is immutable, none of its member 
variables will _ever_ be altered. It guarantees _nothing_ about variables 
external to the object, and impure function can access pretty much anything 
external to an object via module level or static functions or variables, so an 
impure function could return literally _anything_ and could vary on every call 
even if the object is immutable. Any impure member function which uses values 
external to the object has to worry about the thread-safety of those values. 
The thread-safety of the object itself is guaranteed, but that's all.

- Jonathan M Davis


More information about the Digitalmars-d mailing list