Persistent list

Jonathan M Davis via Digitalmars-d digitalmars-d at
Sun Nov 15 06:42:23 PST 2015

On Sunday, 15 November 2015 at 14:34:45 UTC, Dicebot wrote:
> On Sunday, 15 November 2015 at 14:23:05 UTC, Jonathan M Davis 
> wrote:
>>> As I mentioned, he's okay with changing the language to make 
>>> the casts well defined. -- Andrei
>> Well, that's a big change, since it pretty much means that D's 
>> const isn't physical const anymore, and Walter has been _very_ 
>> insistent about that in the past - to the point that he's 
>> argued that C++'s const is outright useless because it isn't 
>> physical const. If casting away const and mutating is 
>> well-defined behavior, then we basically have C++'s const 
>> except that it's transitive ...
> Casting away _const_ is already legal if programmer can himself 
> guarantee underlying object has mutable origin (i.e. not 
> available via immutable reference), by the very definition of 
> const. It is casting away immutable and mutating that is 
> strictly UB.

No. As it stands, casting away const and mutating is _always_ 
considered undefined behavior, regardless of whether the object 
being referred to is actually mutable, const, or immutable. In 
fact, there was a discussion on that not long ago, and the spec 
was updated to be clearer on that count - with approval from 
Walter. AFAIK, it has never been the case that casting away const 
and mutating was defined behavior in D2 (I have no idea what the 
deal with D1 and const is other than the fact that it was quite 

- Jonathan M Davis

More information about the Digitalmars-d mailing list