Poll: a nonstate keyword

Fawzi fawzi at gmx.ch
Mon Jun 2 02:59:12 PDT 2008


Fawzi Mohamed Wrote:

> 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.

actually from the discussion I reconsidered (again) a little my position because I realized that the safe variant (together with an unsafe cast) gives what I want.
So yes either there is a tacit agreement that it is ok in extreme case to modify an object that was created as mutable then made const and maybe even passed as argument to a pure function (thus invariant into it) through a cast (no read only memory or things like it), or I would like to have the no_state keyword.
 
> > 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.

well maybe I should say that what is keeping me away from D2.0 is the fact that I want to do some real work into it, and already in D 1.0 I got side tracked into many side tasks, and I am afraid that the transition to D 2.0 will be even more time consuming.
Furthermore I use GDC (mac and AMD64), and GDC has just began supporting D 2.0, so I think that I will encounter even more issues.
Probably with the next GDC version (and my project further along) I will give it a real try.

Fawzi



More information about the Digitalmars-d mailing list