|
|
|
|
|
by brundolf
1386 days ago
|
|
I love the semicolon rule, I think that distinction is extremely important and too often gets muddled (though in Rust's case I think it's more accurate to say it distinguishes between "statements and expressions" than "procedures and functions") |
|
Yes, the distinction is important. That's why it's extremely annoying that this distinction is almost invisible if you don't look very close on the code using magnifying glasses. Like I said: Marking such an important distinction through something almost invisible like a (missing) semicolon is pure craziness.
Usually nobody reads semicolons! They are usually just line noise coming form a time as parsing code was actually still some kind of science and people made syntax with the explicit intent to be easy readable by archaic computers (and not humans in the first place).
I think `return`s are superfluous but given the choice between some more line noise in the form of a `return` statement and this semicolon brain-fart I would clearly prefer the `return`…
> (though in Rust's case I think it's more accurate to say it distinguishes between "statements and expressions" than "procedures and functions")
Since when? Did I miss something? (This could be, I'm looking only occasionally into Rust).
AFAIK leaving out the semicolon is only an option on the last expression of a procedure, turning that "procedure" into a function.
Leaving out (the completely unnecessary!) semicolons elsewhere is a syntax error to my best knowledge.
The above code would not compile, afaik, because the semicolon is missing on the first line of the procedure.The completely unnecessary semicolons are just one of the examples that make the Rust syntax heavyweight and needless noisy for no good reason. I don't get how a modern language can fall back to such antique syntax.
The very rare use-case where you really want to write some comprehensive one-liner could have been easy supported by optional semicolons. But in the general case one just doesn't need that line noise.
Rust is a great language, really! But they obviously didn't put any effort into the syntax. The result is that the language reads partly like C++, and I guess almost everybody could agree that C++ has one of the most terrible syntax out there.
Rust is "modern" language with a stone age look & feel. That's a big missed opportunity, imho.