The Status of Const
Steven Schveighoffer
schveiguy at yahoo.com
Fri Aug 13 06:41:38 PDT 2010
On Thu, 12 Aug 2010 22:23:30 -0400, Adam Ruppe <destructionator at gmail.com>
wrote:
> On the subject of rebindable, what about:
>
> const Object o; // not rebindable, the whole thing is set once and const
> const(Object) o; // the Object is const, but the reference is not.
>
> So, everything is rebindable unless the declaration has a
> const/immutable on the outside.
>
> int a; // rebindable (obviously)
> const(int) a; // the int never changes... but the variable a might.
> Meaningless for a value type, but makes sense for a reference type
> const int a; // the whole thing is set once and never changes. The
> const applies to the variable a itself, but the transitive property
> propagates it down to the int type too.
This was tried in an early version of D2 const. It is too confusing. For
const(int) to be modifiable is unacceptable. I know it looks appealing,
but trust me, you have about as much chance of convincing Walter to
revisit this idea as you have of walking on water.
-Steve
More information about the Digitalmars-d
mailing list