r/ProgrammingLanguages • • Oct 19 '26

Borrow Checking Zero-Cost Cyclic Mutability

https://antelang.org/blog/safe_cyclic_mutability/
34 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/initial-algebra Oct 19 '26 edited Oct 19 '26

I'd push back on any of the rules for loops or closures being hacky. They follow rules for moves 1:1 so I think they're quite clean actually.

Maybe those ones aren't "hacky" per se, but reasoning about "when can a p! exist" and "when can p be mutated" in terms of sets of program points that must be disjoint (and then making the leap to abstraction over sets of program points) is a unifying semantic principle vs. having ad-hoc syntactic rules for those constructs.

The relationship is already encoded in the unstable place so I don't think a new trait would be necessary

Currently, you could infer Stabilize p from the mention of p!, but, in general, a function would still need to mention Stabilize p even if it only ever creates and uses p! references internally, to prevent a concurrent Mutate p from existing.

The invalidation rules already model the immutability rule you mention.

Yes, but the point of reframing stability as immutability of a special field is to generalize to immutability for other purposes, such as multi-threading.