3 ms·
Rust did a lot of things nice, but it is over cluttered with all these particularities everywhere, which could be hidden by better default conventions. For exa
by throwaway487548 8y ago
Rust did a lot of things nice, but it is over cluttered with all these particularities everywhere, which could be hidden by better default conventions.
For example, everything should be a reference by default, and use of explicit & is stylistically bad.
Or why in
let mut iter = a.iter();
iter is mut? It should be a simple closure which follows a protocol. In what sense it is mutable?
And such small warts are literally everywhere, together resulting in a clutter.
A functional language uniform defaults (everything is an expression, everything is a binding which implies everything s reference) are much better.
- steveklabnik 8y agoIterators contain internal state that gets mutated as you iterate. So it needs to be mutable.
- throwaway487548 8y agoBut the whole idea is that once a closure implements an interface its internal state is strongly isolated behind the abstraction barrier of the interface and no one knows or cares whatever state it has, if any. It is very CS 101.
- steveklabnik 8y agoWell, first of all, it's not a closure, it's a struct, though closures are syntax sugar for structs. Second, what you said is true, but also not really relevant; mutability is part of the API in Rust, and so that is part of the interface. To make it more concrete, https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#tymethod.next https://doc.rust-lang.org/stable/std/iter/trait.Iterator.htm..., the protocol, takes &mut self. So it must be mutable. It's following the principle you're talking about.