Persistent list
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sat Nov 14 15:48:55 PST 2015
On 11/15/2015 12:20 AM, Andrei Alexandrescu wrote:
> On 11/14/15 5:49 PM, Timon Gehr wrote:
>> It's supposed to guarantee that the given reference is not used to
>> transitively mutate the object. The casts violate this.
>
> I think that semantics needs to change. Specifically, either we add a
> @mutable attribute (which means const doesn't apply to fields marked as
> such and immutable objects cannot be created); or we could just decree
> that if a const object originates in a mutable object, casts should be
> well-defined. -- Andrei
>
There's also this closely related situation:
https://issues.dlang.org/show_bug.cgi?id=9149
(I.e. delegates with mutable context pointer can be implicitly converted
to delegates with const context pointer, but when type checking the
delegate, a mutable context pointer is assumed.)
More information about the Digitalmars-d
mailing list