Is that really some "special behavior"? As far as i understand the semicolon is just an expression separator like in Erlang and Pascal. In contrast, the semicolon is a statement terminator in C. C uses the comma for expression separation. Practically everything is an expression in Rust, even blocks, so foo() => evaluates to the return value of foo { foo() } => evaluates to the return value of foo { foo(); } => evalua…
That's what makes it elegant: it lets you omit the return statement (safely) but otherwise looks exactly the same as C, even though it's semantically different.
Such a Little Thing: The Semicolon in Rust
31–40 of 81 posts
Re: Such a Little Thing: The Semicolon in Rust
#32I memorably referred to Rust's significant semicolons as "the worst thing in the language" after my very first read through the tutorial, last November. Almost a year later, I'm just as in love with Rust's semicolon rules as Armin is. However, I bet new users will still be just as instinctively revolted as I initially was.
Re: Such a Little Thing: The Semicolon in Rust
#33Earlier quoted context omitted.
That's what makes it elegant: it lets you omit the return statement (safely) but otherwise looks exactly the same as C, even though it's semantically different.
parsimony =/= elegance
Re: Such a Little Thing: The Semicolon in Rust
#34Earlier quoted context omitted.
I'd rather have significant semi-colons than significant whitespace[1]. Don't mix presentation and semantics. 1: http://c2.com/cgi/wiki?SyntacticallySignificantWhitespaceCon...
Just like Python, Haskell only ever has significant indentation.
Re: Such a Little Thing: The Semicolon in Rust
#35Earlier quoted context omitted.
Hello American. I'm from one of those other pesky countries that make up most of the human population of earth, and which usually have other keyboard layouts. I have to type shift+, to get the semicolon.
Which keyboard layout is that?
Re: Such a Little Thing: The Semicolon in Rust
#36Are semicolons annoying to type? Probably, I got used to them The semicolon is the least-annoying non-letter character to type. It's right there on your home row.
Hello American. I'm from one of those other pesky countries that make up most of the human population of earth, and which usually have other keyboard layouts. I have to type shift+, to get the semicolon.
Re: Such a Little Thing: The Semicolon in Rust
#37We're trying to mix logic that executes on each element in a sequence, with logic that controls how to iterate over that sequence. That is, a "return 42" statement will tell .each to stop iterating, but its contained within a block that is supposed to do things to individual elements.
The mathematical concept just doesn't sit right with me.. I guess if all you have as an iterator is 'each' then that would necessitate finding an additional way to modify iteration in some way, but still.. I don't like the fact that a return statement can break out of something outside of its own scope
edit: even the low-level alternative seems nicer
for(blah;blah;blah) {
stuff;
}Re: Such a Little Thing: The Semicolon in Rust
#38Take a look at Haskell for a very clean and expressive syntax without (required) semicolons.
I'd rather have significant semi-colons than significant whitespace[1]. Don't mix presentation and semantics. 1: http://c2.com/cgi/wiki?SyntacticallySignificantWhitespaceCon...
Re: Such a Little Thing: The Semicolon in Rust
#39Re: Such a Little Thing: The Semicolon in Rust
#40Are semicolons annoying to type? Probably, I got used to them The semicolon is the least-annoying non-letter character to type. It's right there on your home row.
Hello American. I'm from one of those other pesky countries that make up most of the human population of earth, and which usually have other keyboard layouts. I have to type shift+, to get the semicolon.