It also means you can't put more expressions on the same line because doing so requires a semi-colon which then eliminates the special semicolon behavior. Having an explicit 'ret' keyword means you could accomplish that and have more expressions for a separate block on the same line if desired.
Such a Little Thing: The Semicolon in Rust
41–50 of 81 posts
Re: Such a Little Thing: The Semicolon in Rust
#42Earlier quoted context omitted.
Which keyboard layout is that?
Norwegian. Many european countries use the same placement for semicolon. All the Scandinavian and Baltic countries, Germany and Netherlands to name a few. Russia uses shift+4. Can't imagine how annoying that is.
Re: Such a Little Thing: The Semicolon in Rust
#43Re: Such a Little Thing: The Semicolon in Rust
#44However, that template code was utterly hideous.
Re: Such a Little Thing: The Semicolon in Rust
#45Earlier quoted context omitted.
It's odd because people think of semicolons as the end of a statement, not a delimiter between statements.
Which is usually wrong.
Re: Such a Little Thing: The Semicolon in Rust
#46Earlier 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.
A potential workaround is to always use an American keyboard. It's what I do.
Still, even on an American keyboard () are not terribly well placed.
I've been thinking about adopting the NEO2 layout(with some modification so that I get all of åäö) but haven't gotten around to it yet. Has anyone tried that for programming?
Re: Such a Little Thing: The Semicolon in Rust
#47Is 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…
There was some discussion about doing this in D, and there was some in C++11, too. I argued that the presence or absence of the ; did not visually stand out very well, and so would be a source of confusion and errors. Hence, ; remained as a statement terminator, and the return keyword served to indicate returning an expression. However, the D lambda syntax does not require a ; when the lambda body consists of only a…
Though I can think of an even more crazy variation. Declare the semicolon a binary operator and allow overloading it.
As funny as that sounds, Haskell provides something like this, as do-notation can behave differently depending on the monad it is in.
Re: Such a Little Thing: The Semicolon in Rust
#48Earlier quoted context omitted.
A potential workaround is to always use an American keyboard. It's what I do.
Indeed. On a Swedish keyboard the semicolon is not the biggest problem though. {}[] are since you need to press right-alt+number keys to get them. Really awful. It takes a very short time using an American keyboard for coding to realize its benefits. Still, even on an American keyboard () are not terribly well placed. I've been thinking about adopting the NEO2 layout(with some modification so that I get all of åäö) b…
I have all my symbol characters easily accessible from the normal A-Z keys using a third shift state. It's awesome, and works with any keyboard layout (QWERTY, or even Swedish QWERTY are all fine, as is Dvorak, Colemak etc). Typing a previously uncomfortable sequence like "for (int i = 0; i It takes about two weeks to get used to. If you try it, make sure the third shift state can be accessed from either hand (i.e. you have to have left and right keys, just like with shift or control).
I wasn't aware of NEO2 so I developed my own symbol layout using a genetic algorithm running over my code corpus, then adjusting to taste.
Re: Such a Little Thing: The Semicolon in Rust
#49Earlier quoted context omitted.
There was some discussion about doing this in D, and there was some in C++11, too. I argued that the presence or absence of the ; did not visually stand out very well, and so would be a source of confusion and errors. Hence, ; remained as a statement terminator, and the return keyword served to indicate returning an expression. However, the D lambda syntax does not require a ; when the lambda body consists of only a…
Ignoring a potentially wanted return value with ";" is a hazard. I'd like to institute some set of "warn-unused-result" warnings in Rust to combat this.
Re: Such a Little Thing: The Semicolon in Rust
#50Earlier quoted context omitted.
Just like Python, Haskell only ever has significant indentation.
Untrue. While it's true that most people use the 'layout' rule, which is the significant whitespace, there is a non-whitespace-significant variant that uses braces and semicolons. You can see an example of how layout is expanded to the alternative syntax at http://www.haskell.org/onlinereport/lexemes.html#lexemes-lay...