I appreciate, so much, that rust is slowly evolving into perl.
What Rust's syntax really reminds me of is Algol 68, or BLISS, both of them being these old procedural languages where everything is an expression. The "loop { ... break expr; ... }" thing reminds me of BLISS's "exitloop expr" construct.
There's so many programming languages (low barrier to create) that there's a ton of overlap and evolutionary changes/similarities between them. I was thinking of perl's "do { x } while foo" style constructs in this particular case.
I am incredibly amused that I got downvoted to -1 for mentioning perl though. People here are Weird.
> What practical value is it to users to allow "return <expr>" to itself be an expression?
Now, what if I need to return an error?
The expression arms need to be the same type (or what is the type of `name`?). So now the type of the last branch is !. (Which as you hopefully learned from TFA, coerces to any type, here, to &str.)There's more ways this "block statements are actually expressions" is useful. The need not be a ternary operator / keyword (like C, C++, Python, JS, etc.):
In fact, if you're familiar with JavaScript, there I want this pattern, but it is not to be had: Similarly, loops can return a value, and that's a useful pattern sometimes: And blocks: > Even if you disagree with this argument, this design decision has resulted in all these weird/confusing but absolutely useless code examplesI think one can cook up weird code examples in any language.