How do "pure" member functions work?

Don nospam at nospam.com
Sun Aug 21 12:10:09 PDT 2011


bearophile wrote:
> Sean Eskapp:
> 
>> Oh, I see, thanks! This isn't documented in the function documentation!
> 
> D purity implementation looks like a simple thing, but it's not simple, it has several parts that in the last months have be added to the language and compiler, and we are not done yet, there are few more things to add (like implicit conversion to immutable of the results of strongly pure functions). It will need several book pages to document all such necessary design details.
> 
> Bye,
> bearophile

It is actually very simple: a function marked as 'pure' is not allowed 
to explicitly access any static variables.
Everything else is just compiler optimisation, and the programmer 
shouldn't need to worry about it.


More information about the Digitalmars-d-learn mailing list