3 ms·
The thing I'm most concerned with is that the syntax is fucked. A T& should be an Arc<RefCell<T>>, i.e. the most permissible thing, and you should have to wrap
by anon4 11y ago
The thing I'm most concerned with is that the syntax is fucked. A T& should be an Arc<RefCell<T>>, i.e. the most permissible thing, and you should have to wrap it in other things to remove capabilities, rather than add them. The idea being that the short thing is applicable everywhere and probably what you want, while stronger guarantees require more typing.
- Rusky 11y agoThe most permissible thing is not the most used thing (&T is far more common than Arc<RefCell<T>>), and Rust's goal is to be explicit about costs. The extra typing directly correlates with extra cost.
- Jweb_Guru 11y agoJust FYI, `Arc<RefCell<T>>` wouldn't actually be useful, because you could not send it to other threads (`RefCell<T>` is not `Sync`). By your definition the "most permissive" thing would be `Arc<Mutex<T>>` and that hopefully makes it clearer why this would be a terrible default (`RefCell` has similar tradeoffs to those of a `Mutex` that killed your program when it detected deadlock, and `Arc` can leak memory). Rust absolutely gets the tradeoffs right here. BTW, if you want a language where refcounting is the predominant approach (and where the compiler is built around it), but is otherwise very similar to Rust, you almost certainly want Swift.