In Rust, the semicolon is the expression sequencing operator (like in ML), not a statement terminator. "a;b" means "evaluate a, throw away the result, and return the result of evaluating b". So the semicolon is more than just boilerplate.
I guess we could do some sort of automatic semicolon insertion like JavaScript, but I'm not sure that the benefits outweigh the complexity.
/*
* Go language grammar.
*
* The Go semicolon rules are:
*
* 1. all statements and declarations are terminated by semicolons.
* 2. semicolons can be omitted before a closing ) or }.
* 3. semicolons are inserted by the lexer before a newline
* following a specific list of tokens.
*
* Rules #1 and #2 are accomplished by writing the lists as
* semicolon-separated lists with an optional trailing semicolon.
* Rule #3 is implemented in yylex.
*/
But obviously this is very language-specific and given the case discussed above likely not to work in quite the same way.
Hey - I know this is trivial, but I just find it takes away from the clarity of the code when you must terminate lines with a semicolon.
It's obviously very useful to use ';' in the scenario you mention, I think a good comparison is F# which doesn't force semicolons but does permit usage like that. I guess, e.g.:-
foo
bar
baz
implies foo |> ignore; bar |> ignore; baz
Oh, and just to make it very clear, I am talking about something really rather petty, I do not mean to do down rust in any serious way - I'm a wannabe-language designer myself, so major respect to you guys :)
In Rust, the semicolon is the expression sequencing operator (like in ML), not a statement terminator. "a;b" means "evaluate a, throw away the result, and return the result of evaluating b". So the semicolon is more than just boilerplate.
I guess we could do some sort of automatic semicolon insertion like JavaScript, but I'm not sure that the benefits outweigh the complexity.