Pure

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Wed Jan 8 10:40:45 PST 2014


Is pure meant to be a compiler hint so that it is up to the 
programmer to enforce it? It is sometimes useful to maintain 
hidden state for lazy evaluation, that does not affect purity 
optimizations:

e.g.

a = foo(1) // evaluates, caches and returns value
b = foo(1) // returns cached value
c = foo (1) // returns cached value

is optimized to

a = b = c = foo(1) // evaluates, caches and returns value



More information about the Digitalmars-d-learn mailing list