How about 'pure' for constants?

Alexander Panek alexander.panek at brainsware.org
Wed Dec 12 04:35:55 PST 2007


On Tue, 11 Dec 2007 09:33:40 +0100
Don Clugston <dac at nospam.com.au> wrote:

> Seems to fit with the idea of 'having no side-effects' - a pure value
> would not be stored anywhere, and make no contribution to the size of
> the executable.
> 
> pure real pi = 3.141592564;
> 
> // this is really silly if you use 'enum' instead.
> pure real myNaN = real.nan;
> 
> BTW, a pure function taking only pure parameters returns a pure
> value, so this seems to be entirely consistent:
> 
> pure int foo(int a, int b);

I like that very much.

-- 
Alexander Panek <alexander.panek at brainsware.org>



More information about the Digitalmars-d mailing list