@mutable
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 21 10:58:01 PST 2016
On Sunday, 21 February 2016 at 15:03:39 UTC, Marc Schütz wrote:
> I've adapted my previous DIP on lazy initialization to make it
> usable for logical immutability, as is useful for reference
> counting, among other things:
>
> http://wiki.dlang.org/DIP89
From the DIP:
> The second rule (@system) prevents accidental accesses that
> violate [logical const-ness]
It seems we could use @mutable as a method attribute instead of
@trusted const. The advantage would be that code is still checked
for @safety. Requiring it still helps to prevent unintentional
mutation and remind the programmer about correct logical const
encapsulation. I realise @trusted has more impact but really here
this use isn't related to memory safety, (or is it)?
More information about the Digitalmars-d
mailing list