Fully transitive const is not necessary

Sean Kelly sean at invisibleduck.org
Thu Apr 3 13:41:21 PDT 2008


== Quote from Janice Caron (caron800 at googlemail.com)'s article
> On 02/04/2008, Sean Kelly <sean at invisibleduck.org> wrote:
> > My traditional argument in support of logical const is this:
> >
> >     class C
> >     {
> >         mutable mutex monitor;
> >         <snip>
> >     };
> But in D, the class C will already have a mutex, by virtue of the fact
> that it derives from Object.

Yup.  I did mention object-local logs or other similar things, but mutexes
are far and away my most common use of mutable in C++.  So no worries
here in D.

> ...which raises an interesting point. Can "synchronized" be used on a
> const object? What about an invariant object?

They'll work just fine with const objects in D.  Object monitors in D currently
live outside the const checking scheme.


Sean



More information about the Digitalmars-d mailing list