Fully transitive const is not necessary
Walter Bright
newshound1 at digitalmars.com
Wed Apr 2 15:22:39 PDT 2008
Janice Caron wrote:
> However, I suspect that the following will be OK.
>
> enum g = 42;
>
> pure int f()
> {
> return g;
> }
Yes, because the value of g can never change.
The way to think about pure functions is that if the arguments are the
same, the result will be the same. This precludes reading any global
state that could change, and precludes writing to any global state.
But global invariants and manifest constants cannot ever change state,
and cannot be written to, so using them in a pure function is ok.
More information about the Digitalmars-d
mailing list