6 ms·
Rust ownership model ("stacked borrows" I believe it's called) is basically this
by vimwizard 6mo ago
Rust ownership model ("stacked borrows" I believe it's called) is basically this
- LoganDark 6mo agoActually there's tree borrows now. https://www.ralfj.de/blog/2023/06/02/tree-borrows.html https://www.ralfj.de/blog/2023/06/02/tree-borrows.html
- NooneAtAll3 6mo agoI think it's the other way around - he's projecting rust as what he wants
- kibwen 6mo agoSingle-ownership ("affine types") is a separate concept from a borrow checker. Your language doesn't need a borrow checker (or references at all) to benefit from single-ownership, though it may make some patterns more convenient or efficient.
- ChadNauseam 6mo agorust would be pretty unusable without references. affine lambda calculus isn’t even turing complete. however, you’re right that a borrow checker is unnecessary, as uniqueness types (the technical term for types that guarantee single ownership) are implemented in clean and idris without a borrow checker. the borrow checker mainly exists because it dramatically increases the number of valid programs.
- kibwen 6mo agoSupporting single-ownership in a language doesn't mean you can't have opt-in copyability and/or multiple-ownership. This is how Rust already works, and is independent of the borrow checker. If we consider a Rust-like language without the borrow checker, it's obviously still Turing-complete. For functions that take references as parameters, instead you would simply pass ownership of the value back to the caller as part of the return value. And for structs that hold references, you would instead have them hold reference-counted handles. The former case is merely less convenient, and the latter case is merely less efficient.