3 ms·
JavaScript messed it up, but Python did it well. A newline is a statement separator, unless it's e.g. between parentheses where a statement separator wouldn't m
by duckerude 6y ago
JavaScript messed it up, but Python did it well. A newline is a statement separator, unless it's e.g. between parentheses where a statement separator wouldn't make sense. Unlike JavaScript, that means you don't have to look at the next line to figure out whether the statement continues.
JavaScript assumes a newline doesn't end a statement, until proven otherwise. Python assumes it does end a statement unless it very clearly can't.
It's independent from Python's other significant whitespace, so you could use it in a more "C-like" syntax.
But it wouldn't be a good fit for Rust. In Rust, leaving the semicolon off the final statement in a block already changes its meaning, so that would become ambiguous. It also uses method chaining syntax a great deal more than Python, which is a bit awkward because you have to wrap the expression in parentheses (though autoformatting helps). And of course it would break most existing code.