Const system names
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Tue Feb 16 01:28:28 PST 2010
bearophile wrote:
> Alternative names for the transitive const regime of D2, the main difference is that now immutable values are the default:
>
> - "immutable" ==> (nothing, it's the default).
> - "const" ==> "valview" (a local immutable value view of something).
> - mutable variable ==> "var"
> - "enum" ==> "const" (or maybe it can be removed, so it becomes immutable, that is no annotation. The link-time optimization of LDC is able to remove unused values from the binary. Ten years from now all D compilers can be able to do this).
>
> [...]
I don't agree that immutable should be the the default. The default
should be the most common case, which is mutable.
Regarding names; the fact that we currently have to write "enum x =
123;", which to me reads like "enumerate this single constant for me
please, and BTW when I say 'enumerate' I really mean that I want to
assign 123 to it", is one of the last remaining things in D that really
bugs me.
I have suggested the following scheme at least twice:
const: manifest constants, no storage (like const in D1, enum in D2)
readonly: a read-only view of mutable data (like const in D2)
immutable: immutable data (like now)
(Both times Yigal Chiprun was the first to reply, saying he thinks there
should only be const and non-const, and the rest is up to the compiler.
I'd almost be disappointed if that doesn't happen now. :) I still
disagree, though.)
-Lars
More information about the Digitalmars-d
mailing list