Poll: a nonstate keyword
Fawzi Mohamed
fmohamed at mac.com
Thu May 29 11:14:20 PDT 2008
On 2008-05-29 18:41:21 +0200, "Steven Schveighoffer"
<schveiguy at yahoo.com> said:
> 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?
I already expressed my view about it in
http://www.wikiservice.at/d/wiki.cgi?TransitiveConst
I think that it is a good idea, but I think that its name should be
much uglier unsafe_mutable, and should be seen by everybody in the
community as a bad, and not to be used.
Basically it is an unsafe hole that allows to implement nice an useful
stuff (suspended values(lazy eval & cache), dataflow variables,
memoization, performace/statistical information), but can break
invariant and introduce subtle bugs.
> Would you stop using D because of it?
no
> Would you switch to D2 because of it?
no
> Would you consider this concept hard to explain or understand?
no, but hard to use correctly if it really breaks the invariance, and
not much useful if it does not break invariance.
Fawzi
More information about the Digitalmars-d
mailing list