On 11/10/2011 2:00 AM, Russel Winder wrote:
Purity is not really something I understand here without some lead in. I guess I failed to read part of Andrei's book ;-)
A pure function in D is one that has no side effects. It is set by adding the keyword "pure" to a function, and is checked by the compiler.
A pure function may not modify any data reachable through its parameters, may not read or write to any mutable global state, and can only call functions that also are either pure or restrict the variables they modify to those of the calling pure function's.
A pure function may allocate data via new, and may throw an exception.