mutability

Borrow Checking Zero-Cost Cyclic Mutability

Ante is a low-level1 functional language built on ownership semantics and borrowing, similar to Rust. Unlike Rust, however, a core goal of Ante is to be more lenient in its borrow checker, notably by relaxing Rust’s rule that you can either alias a reference or mutate it, but never both at the same time. // In Rust: letmutmy_tuple=(1,2);letfirst_elem=&my_tuple.0;// error[E0506]: cannot assign to `my_tuple` because it is borrowed my_tuple=(3,4);println!("{first_elem}");I wanted to allow for code like the above while still disallowing code that would lead to dangling pointers, and I wanted to do this entirely statically in the type system.

Continue reading

Stable, Mutable References

Introduction In my first blog post I introduced &shared mut references as a way to achieve safe, shared mutability in a language with unboxed types. For more information on those, start with the first blog post. As a brief summary though, &shared mut references can be aliased freely and mutate freely with the one restriction of not being able to be projected into any “shape-unstable” types. What is a shape-unstable type?

Continue reading

Achieving Safe, Aliasable Mutability with Unboxed Types

This is part of Ante’s goal to loosen restrictions on low-level programming while remaining fast, memory-safe, and thread-safe. Update: The syntax of Ante code snippets has been updated to reflect Ante’s current syntax. Background When writing low-level, memory-safe, and thread-safe programs, a nice feature that lets us achieve all of these is an ownership model. Ownership models have been used by quite a few languages, but the language which popularized them was Rust.

Continue reading