Re:Rust severely disappoints me
by Manishearth on Thursday January 12, 2017 @03:49PM
(#13385978)
Ruby has a similar pattern. It's a pretty popular language.
Correlation is not causation. Having return expressions does not make or break a language.
Python and JS do have return expressions in the context of lambdas.
I'm not very fond of this pattern in untyped languages (Ruby, Perl) because it can lead to accidental returns, but I'm pretty happy with having it in a typed language.
Re:Rust severely disappoints me
by lobster_johnson on Thursday January 12, 2017 @05:00PM
(#13386532)
JavaScript supports implicit return in anonymous functions:
let lowercased = names.map(name => name.toLowerCase());The thing all those languages have in common is mutability by default. Being able to return values from if/else eliminates a lot of variables that would need to be mutable otherwise.
You can do some very nice things with that sort of syntax. Being able to assign values based on an if statement is one example that just makes life a little better. Just a tiny bit. :)
Re:Rust severely disappoints me
by GFK_of_xmaspast on Thursday January 12, 2017 @03:47PM
(#13385958)
Perl has implicit return.
TIOBE Index January 2017. The top 10 languages are Java, C, C++, Python, Visual Basic, Javascript, Perl, Assembly, PHP
Except for Assembly, where the comparison makes no sense, all of these languages have return expression. Yes, there are other languages that use last expression but they are most definitely not common languages and the most common languages use return expression.
It just seems unnecessary. It isn't clear what they got out of it.