4 ms·
Do you have a written source for this? What you're describing is nice, but I can see so many basic cases in which it doesn't work, at least not without a borrow
by Yoric 3y ago
Do you have a written source for this? What you're describing is nice, but I can see so many basic cases in which it doesn't work, at least not without a borrow analysis much more sophisticated than Rust's, that I imagine I'm missing something.
Example: A linked list.
Nitpick: Rc and Arc are not traits.
- yashrk 3y agoTwo main papers about this topic AFAIK are: «Counting Immutable Beans» by Sebastian Ullrich and Leonardo de Moura (https://arxiv.org/pdf/1908.05647.pdf https://arxiv.org/pdf/1908.05647.pdf) and «Perceus: Garbage Free Reference Counting with Reuse» by Alex Reinking, Ningning Xie,Leonardo de Moura, Daan Leijen (https://dl.acm.org/doi/pdf/10.1145/3453483.3454032 https://dl.acm.org/doi/pdf/10.1145/3453483.3454032). See also Anton Felix Lorenzen's master thesis: https://antonlorenzen.de/master_thesis_perceus_borrowing.pdf https://antonlorenzen.de/master_thesis_perceus_borrowing.pdf Mr. Feldman also mentioned some «alias analysis» library «Morphic Solver» from Berkley University, but I cannot find anything about it. BTW compile time reference counting was already discussed on HN, for example here: https://news.ycombinator.com/item?id=19567666 https://news.ycombinator.com/item?id=19567666 > Example: A linked list. IIUC recursive data structures like linked list and trees are not the problem for the static reference counting. Mutation (and, therefore, link cycles) _is_ a problem, but Roc is a clean language with no explicit mutation. =) > I can see so many basic cases in which it doesn't work Sometimes runtime reference counting is still used. But, of course, in way more complex situations than just processing a linked list. > Nitpick: Rc and Arc are not traits. Of course, my fault. I haven't written on Rust for a long time (and never used this language in a serious project). edit: link added
- Yoric 3y agoThanks!
- yashrk 3y agoI found what is «Morphic», mentioned by Richard Feldman. It's an another experimental programming language with the static reference counting. «Morphic uses a borrow-based reference counting scheme which is able to eliminate almost all reference count increments and decrements for a large class of programs»ⓒMorphic developer team. Site: https://morphic-lang.org/ https://morphic-lang.org/ Paper: https://dl.acm.org/doi/10.1145/3591260 https://dl.acm.org/doi/10.1145/3591260
- Yoric 3y agoThanks, it makes sense now! I think I've read a post by Niko Matskakis (Rust lead) who suggested doing something similar. That would be exciting to see!