a nonstate keyword
Neil Vice
sardonicpresence at gmail.com
Thu May 29 18:06:47 PDT 2008
"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
news:g1mmbh$ftq$1 at digitalmars.com...
> What if D2 were to introduce a keyword that allows you to decouple a class
> member from the class state for the purposes of const? This keyword
> basically means that the member is stored with the class data but is
> unaffected by the constancy of an instance. In other words, a non-state
> member variable is not cast to const when the class instance is cast to
> const. This is an implementation of the 'is associated with' OO
> relationship. This is similar to the 'mutable' keyword in C++, or the way
> mutexes work in D.
>
> If this were to happen, would you consider this to be a positive,
> negative, or inconsequential change?
This is certainly a feature I've felt the need for in the past, and caching
to me is the obvious use-case.
Having said that, I recall arguments to the effect that there are better
ways to implement such things that don't require the use of such a keyword
and prevent the need to "break" the transitive-const model.
Given this, my current stance is that it should be left out unless it can be
demonstrated that there is a useful design that cannot be implemented
without it, and I will be interested to see if I continue to feel the need
for it when optimising code in future.
More information about the Digitalmars-d
mailing list