April 13

On Wednesday, 13 April 2022 at 12:59:30 UTC, Dennis wrote:

>

On Wednesday, 13 April 2022 at 12:31:44 UTC, Zach Tollen wrote:

>

Maybe there is some other natural use for @system variables. But none of the use cases I have seen seem particularly incompatible with the additional __mutable functionality.

Without conflating @system and __mutable:

struct Boolean
{
    @system ubyte payload; // must be 0 or 1 or buffer overflows could happen
}

immutable Boolean b; // can be placed in read-only data segment

When conflating @system and __mutable, b suddenly must be placed in mutable memory.

On top of this: leaving @system and __mutable separate allows b to be safely accessed from multiple threads without synchronization. If @system and __mutable were combined, this could potentially result in data races, and so would no longer be safe.

It's not hard to imagine situations where one might want to create an immutable copy of a type with @system fields in order to share it between threads.

Next ›   Last »
1 2 3 4 5 6