3 ms·
I've implemented balanced trees with partial sharing of subtrees in Rust too. Just use Rc everywhere.
by kccqzy 10y ago
I've implemented balanced trees with partial sharing of subtrees in Rust too. Just use Rc everywhere.
- rbehrends 10y agoWell, that's my point. Rc<T>/Arc<T> essentially mean: "I can't figure out ownership here; let's use automatic memory management instead". The thing is that this is pervasive in ML (even simple functions like List.rev – functionally reversing a list – are a problem), so you end up having Rc<T>/Arc<T> all over the place. The underlying problem is that pure functions from data structures to data structures create multiple ownership naturally. Remember that this is about the claim that "Rust is very much ML". It really isn't. It's a totally different programming paradigm. That's not bad. Rust does some things very well that ML has a hard time with. But it's not the same.