Head Const

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 17 14:44:27 PST 2016


On 2/17/2016 2:31 PM, Jonathan M Davis wrote:
> We _could_ have something like @mutable on member variables which made them
> mutable in spite of being in a const object and which made it illegal for that
> type to ever be immutable, but we'd be forced to have an additional attribute on
> the type itself (e.g. @contains_mutable) because of the opaque type issue, and
> at that point, the compiler could just look at the attribute on the type to know
> that it couldn't be immutable, and similar to abstract, it could then require
> that any type that it's a member of t hen be marked with that attribute. So,
> it's uglier than simply marking a member variable with @mutable, but it's
> certainly feasible.

It would seem that implementing headconst as a type constructor would let people 
who wanted mutable members have their way, without introducing backdoors in const.



More information about the Digitalmars-d mailing list