5 ms·
I'm going to make a superficial comment and say that "cont" and "ret" are annoying and gratuitous differences. C/C++, Java, Python, JavaScript, and I think Per
by chubot 15y ago
I'm going to make a superficial comment and say that "cont" and "ret" are annoying and gratuitous differences. C/C++, Java, Python, JavaScript, and I think Perl/Ruby/Go all use "continue" and "break". It's just pointless to be different in this respect.
A different concept should use different syntax -- and it looks like Rust has several new concepts where they can invent whatever syntax they want. But the same concept should use the same syntax.
- p4lindromica 15y agoruby uses the next keyword for continue
- mahmud 15y agoC++ and Java iterators use next as well.
- tedunangst 15y agoCalling next on an iterator and continue in a loop do very different things. C++ iterators use ++ too, but even though ++ and loops are often found together, I would not list ++ and continue as even remotely synonymous.
- draegtun 15y agoDitto for Perl. However Perl uses last instead break. NB. Since Perl 5.10 it does have continue & break in its given/when (topicalizer) switch block.
- masklinn 15y ago> "ret" [is] annoying and gratuitous differences. C/C++, Java, Python, JavaScript, and I think Perl/Ruby/Go all use [...] "break" `ret` is a non-local return, it's got nothing to do with `break` (which is a local return and the usual" break). Also, `ret` is in line with the (unfortunate I think) systematic shortening of keywords in Rust: `fn`, `ret`, `mut`, `alt`, ... And as p4lindromica notes, Ruby's `continue` is called `next`.
- gtaylor 15y agoI agree. I was noticing that it really read "odd" to me, like someone was trying to be clever and terse. I don't think saving a few keystrokes is worth the decrease in cosmetic appearance/readability. Indeed, I inferred what those keywords meant, but, yuck.
- queensnake 15y agoThis (my) comment is just noise, but I support the choice of short keywords - it helps in seeing them iconically. It's not the typing, though I think that helps too, but the reading - a long word, you have to /read/. A short sequence of chars is an instantly, right-brain recognized pattern. For that same reason I much prefer '0' to 'NULL' for ptrs in C/C++ to (I'm talking about visually, not type safety).
- nikomatsakis 15y agofwiw, I thought the same when I began work on Rust, but I have since gotten quite used to the shorter keywords. At this point, I can't believe the keywords in other languages are so pointlessly long. But the truth is that whatever the surface syntax is, one quickly gets used to it. What's more important are the core concepts at work.