New blog post!
I've been investigating out how various languages get away with not requiring semicolons.
I looked at 11 languages and found so many interesting cases I had to share!
New blog post!
I've been investigating out how various languages get away with not requiring semicolons.
I looked at 11 languages and found so many interesting cases I had to share!
@terts I would urge you not to go down this road. Stick to mandatory semicolons. If it were entirely my call, I'd take a step *farther* toward mandatory statement terminators, and make
fn returns_b() -> rettype {
a();
b()
}
a syntax error; you would be obliged to write
fn returns_b() -> rettype {
a();
b();
}
and that would return the value returned by b, unlike Rust and current Roto. To return nothing, you would write
fn returns_unit() {
a();
b();
();
}
@terts This is based on extensive experience with C, Rust, Python, Perl, awk, sh, R, and Javascript, and some exposure to Ruby, Go, and Lua (all of which I can read, but avoid using for unrelated reasons).
My experience has been that only the extremes - Python's "the indentation _alone_ determines block structure; use semicolons only to cram multiple statements onto the same line" and C's "you must put a semicolon at the end of every statement" - avoid confusing people with edge cases.
@terts And I dislike Rust's "leave off the last semicolon to make the block evaluate to the value of the last expression instead of to ()" rule because that makes the value of the block change depending on the presence or absence of one character that otherwise has minimal semantic significance, so your brain learns to ignore it.
The type checker will usually flag this when you get it wrong; it would be a much worse problem in a language where bugs like this are runtime errors.