4 ms·
Rust doesn't pass references by default, so I'm not really sure what kind of dichotomy you're trying to draw here. Also, such fundamental changes likely have fa
by burntsushi 8y ago
Rust doesn't pass references by default, so I'm not really sure what kind of dichotomy you're trying to draw here. Also, such fundamental changes likely have far reaching effects that would likely change Rust itself in ways you can't anticipate.
- macintux 8y agoI'm relying on his description: > The biggest issue I have with the defaults, and the borrow checker is that places in FP where you would normally pass by copy — pass by value, in Rust instead it assumes you want to pass by reference. Therefore, you need to clone things by hand and pass the cloned versions instead. Although it has a mechanism to do this automatically, it’s far from ergonomic.
- burntsushi 8y agoYeah, I don't really understand what the OP is trying to say there other than "I'm frustrated." The lack of examples makes it hard to know. Passing by value works just fine in Rust, so it's hard to unpack what the author was getting at.
- macintux 8y agoI'd guess he's referring to this. https://internals.rust-lang.org/t/why-do-i-have-to-indicate-pass-by-simple-reference-or-by-value-in-calling-code/991 https://internals.rust-lang.org/t/why-do-i-have-to-indicate-...
- burntsushi 8y agoYeah, still doesn't make any sense to me. That request is asking for implicit references (a small syntactical change as far as I can tell), which is different from what you asked for and doesn't seem to match up with what the OP wants either. Without examples or further clarification, I don't think it's possible to understand what the OP actually meant.
- sargun 8y agoPlaces where I want automatic cloning: 1. Anywhere I call clone(). That should be the default / automatic. 2. Anywhere where I can get copies than explicitly move for lambdas The problem with the latter is that I have to call clone outside of the lambda and bind it to a short-lived variable into to get moved to the scope of the lambda.
- burntsushi 8y ago(1) is basically saying "Rust should have copy semantics by default instead of move semantics." I'm very glad that's not the case. Those implicit copies would become easy performance foot guns. In most Rust code I write, using `clone` is fairly uncommon, so it's also optimizing for the wrong thing anyway. Finally, things that aren't cloneable are far more common than things that aren't moveable, so you'd need to smooth out that gap as well. (2) is interesting and I'd be happy to see work done there to make that nicer, but it's hard for me to understand that being a big sticking point.