Log in to h4cker, then connect Hacker News to publish comments.
HIhingler3613 часов назад
I can see how multiple mutable references is fine in a single-threaded context, but surely this would cause UB in the multi-thread context?
PAPanzerschrek7 часов назад
I am pretty skeptical about the whole idea about adding such exceptions to the single mutable reference rule. It may be safe to share references to simple structs in terms of raw bytes access, but as long as some non-trivial invariants are involved, it can be a source of nasty bugs.
In my programming language I generally don't allow having more than one mutable reference to a variable. The only exception is when two references point to different elements of structs/tuples. This gives some flexibility without sacrificing correctness.
PAPanzerschrek7 часов назад
> Because of this, Ante code can safely have multiple mutable borrow references to the same struct at the same time.
I doubt it can work in multithreaded code. Allowing sharing mutable references (even to simple structs) means race conditions, temporal inconsistency between different struct fields and even incorrect read results for basic integer types (if the target CPU can't atomically read/write values of types like u64).
UNunknown11 часов назад
[deleted]
SUsureglymop14 часов назад
What about Vale? Is this a rename of it or something new?
Comments
5 preview comments · loading full threadLog in to h4cker, then connect Hacker News to publish comments.
I can see how multiple mutable references is fine in a single-threaded context, but surely this would cause UB in the multi-thread context?
I am pretty skeptical about the whole idea about adding such exceptions to the single mutable reference rule. It may be safe to share references to simple structs in terms of raw bytes access, but as long as some non-trivial invariants are involved, it can be a source of nasty bugs. In my programming language I generally don't allow having more than one mutable reference to a variable. The only exception is when two references point to different elements of structs/tuples. This gives some flexibility without sacrificing correctness.
> Because of this, Ante code can safely have multiple mutable borrow references to the same struct at the same time. I doubt it can work in multithreaded code. Allowing sharing mutable references (even to simple structs) means race conditions, temporal inconsistency between different struct fields and even incorrect read results for basic integer types (if the target CPU can't atomically read/write values of types like u64).
[deleted]
What about Vale? Is this a rename of it or something new?