News for hackers. Stuff that matters.
Re:Systems Languages: An Experience Report by macintux on Friday July 06, 2018 @03:04PM (#17474222)
I believe that reinforces Sargun’s point.

One of the reasons I love functional programming is it allows me to think less about edge cases, because values are passed as values.

If Rust passed copies instead of references by default, people who wanted performance could fight (or embrace, whatever your preferred term/level of experience is) the borrow checker, while everyone else could enjoy the fundamental safety of not sharing data.

Re:Systems Languages: An Experience Report by burntsushi on Friday July 06, 2018 @04:23PM (#17474816)
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.
Re:Systems Languages: An Experience Report by macintux on Friday July 06, 2018 @04:41PM (#17474914)
I'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.

Re:Systems Languages: An Experience Report by burntsushi on Friday July 06, 2018 @04:50PM (#17474981)
Yeah, 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.
Re:Systems Languages: An Experience Report by macintux on Friday July 06, 2018 @04:55PM (#17475025)
Re:Systems Languages: An Experience Report by burntsushi on Friday July 06, 2018 @05:08PM (#17475129)
Yeah, 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.

Re:Systems Languages: An Experience Report by sargun on Friday July 06, 2018 @06:58PM (#17475749)
Places 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.

Re:Systems Languages: An Experience Report by burntsushi on Friday July 06, 2018 @08:29PM (#17476143)
(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.