Const sucks
Walter Bright
newshound1 at digitalmars.com
Mon Sep 10 15:26:26 PDT 2007
Gregor Richards wrote:
> const has a more limited use for optimization than invariant, since the
> value could be changed by other threads/programs-with-shm/whatever from
> under you.
const is useless for optimization, invariant is very useful for
optimization. But it turns out that if you have invariant, soon you'll
discover that you need const. Otherwise you'll find that every function
will have to be implemented two or more times (*).
(*) Because invariants cannot be implicitly converted to mutable, and
vice versa.
More information about the Digitalmars-d
mailing list