|
|
|
|
|
by yashrk
944 days ago
|
|
Rc and Arc traits are implementations of the _runtime_ reference counters. Runtime reference counting is sometimes less efficient than tracing GC. But Roc counts references in _compile_ time. So it's like _usual_ (not wrapped in Rc<>) values in Rust. But in Rust the value is deleted from the heap when the stack frame with the _only_ link to it («the owner») is deleted. And in Roc the value is deleted from the heap, when the _last_ link to it leaves the stack. So we have the machine code _almost_ as efficient as a Rust-produced machine code, but the source code with a much simpler semantics. |
|
Example: A linked list.
Nitpick: Rc and Arc are not traits.