Dicebot on leaving D: It is anarchy driven development in all its glory.

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Aug 29 19:16:08 UTC 2018


On Wed, Aug 29, 2018 at 07:02:42PM +0000, Dave Jones via Digitalmars-d wrote:
> On Wednesday, 29 August 2018 at 18:02:16 UTC, Timon Gehr wrote:
> > On 29.08.2018 19:15, H. S. Teoh wrote:
> > > On Wed, Aug 29, 2018 at 06:58:16PM +0200, Timon Gehr via
> > > Digitalmars-d wrote:
> > > > On 28.08.2018 19:02, H. S. Teoh wrote:
> > > > > On Tue, Aug 28, 2018 at 08:18:57AM +0000, Eugene Wissner via
> > > > > Digitalmars-d wrote:
> > > 
> > > Currently, immutable implicitly converts to const. If const is
> > > allowed to be overridden, then you could violate immutable, which
> > > is UB.  ...
> > 
> > __mutable fields are __mutable also in the immutable instance. You
> > might get into trouble with shared if you are not careful because of
> > the unfortunate "implicit shared" semantics of immutable, but it is
> > up to the programmer to get this right.
> 
> So you cant cast away const but you can specify a field stays mutable
> even if the aggregate is const or immutable?

That appears to be the case.  But it scares me that const(T) would no
longer guarantee you can't modify anything in T.  I fear it will break
some subtle assumptions about how const/immutable works, and introduce
hidden bugs to existing code.


T

-- 
Doubt is a self-fulfilling prophecy.


More information about the Digitalmars-d mailing list