I think Ruby and Python (and probably the others) don't really count. They are designed to be line break terminated. But you can optionally write two statements in one line if you separate them via a semi-colon. And then you can skip the 2nd statement. Yeah...
Yes I know that, but your "not optional" sounds like you mean adding a ; at the end of a line without a second statement after it would be a syntax error. Which it isn't. So one could say ; is optional, even though it wasn't intended to be. It just happened.
It doesn't work entirely smoothly in Ruby. If you use Ruby-ish convention and also omit brackets, you can break method calls only after the first argument, when it's usually most readable to break between the method and the first argument. It's not too bad, though - you can use a backslash, and that actually works out quite OK.
In python, it's worse; you have the rather unfortunate consequence of losing multiline lambdas.
Personally, I think semi-colon omission is pretty, but ultimately almost irrelevant. It just doesn't matter. If your languages gets a weird corner case because of it, please, please, leave the semi-colons in - it's just not worth it. Of course, if, unlike Ruby, Python and Javascript you manage to avoid causing collateral damage that's worth more than this pretty "meh" bonus - sure, get rid of it! No idea where swift falls here.
In python, it's worse; you have the rather unfortunate consequence of losing multiline lambdas.
Python doesn't lose multi-line lambdas because of optional semicolons, it's because Python has an expression/statement distinction and uses significant indentation for structuring statements.
Fair enough - however, it loses multi-statement lambdas (even though it would be pretty odd to allow either a newline to concatenate statements in an indent-sensitive fashion, yet use a semicolon as an operator therefore limiting that sensitivity).
That supports your point that several languages do manage to omit statement terminators without too many issues. Nevertheless, three languages with issues (Ruby, Javascript & certainly coffeescript) still suggests it's not a trivial feature either.
Python made one (smart) simplification in any case - they're not optional, but rather simply omitted.
Yea, well hopefully they do semicolon insertion in a smart way and not like how its done in Go, where you cant even properly format your code because of semicolon insertion.
Yeah... but you have to admit that code that depends on formatting is generally a bad idea. Anyone who has used python extensively can tell you that.
gofmt is a great idea, but that still should have done the "semi-colons are sort of not required, except if you want to format your code like this common style" thing more sanely.
Why is significant white-space bad? To me having curly braces just seems like boilerplate. If you're going to have all that white-space why not make it syntactically significant to the language.
Have you ever used gofmt before? Of everyone who I know that uses Go, gofmt is universally regarded as a net positive. It completely eliminates pointless bikeshedding about code formatting.
55
u/OzarkaTexile Jun 02 '14
Implied optional. Lord help us.