[Issue 24393] Going into ROM operator overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 15 17:57:33 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24393

--- Comment #2 from Richard Cattermole <alphaglosined at gmail.com> ---
You have that backward.

When you are going to mark memory as immutable (and with that potentially
flagged as read only at CPU level), an object needs to be able to alter its
behavior with respect to this.

That is what this method does, it allows it to turn off the mutex so that it
always locks/unlocks without mutation, and to turn off the reference count.

It also means if disabled or missing that the type does not support being in
ROM and hence cannot be immutable.

So we kinda have three options as I see it:

1. Add some way for the object to adjust itself, so that immutable actually
does mean process-wide immutability for a given object.
2. Disallow reference counting and Object to ever be immutable. We would of
course need some way of detecting reference counting and that means we need it
in the language.
3. Remove immutable as it doesn't offer the guarantees that the spec says it
does (and cannot).

This ticket focusses on the first one, as it doesn't break code and strengthens
what guarantees the language "offers".

--


More information about the Digitalmars-d-bugs mailing list