← Back to context

Comment by ameliaquining

4 days ago

This isn't quite right. Go and JavaScript use semicolons pervasively throughout their formal grammars, and mostly don't use newlines; then, on top of that, they have special rules that allow the semicolons to be omitted in many cases depending on newline placement. Python uses newlines pervasively throughout its formal grammar, and only allows semicolons to be used in a couple specific places (at the end of a simple statement or to separate multiple simple statements on a single line).

The two systems have in common that you can either include or omit a semicolon when you've got a simple statement on its own line, but under the hood they're different; the missing semicolon at the end of a line in idiomatic Python is not "automatically inserted by the parser", it is simply not needed at all. There are also behavioral differences; for example, in Go and JavaScript a semicolon on a line by itself is legal and does nothing, while in Python it's a syntax error.

This might might sound weird but I think that's a distinction without a difference.

Those "newline tokens" are effectively the equivalent to a semicolon in the parser. They are statement terminators. The way that Odin or Python handles them is effectively the same except when I tokenize the newlines, they are treated as semicolons but with the "text" being "\n". Thus the distinction here is a matter of what you call it, not how it is treated.

That is the same as a form of "automatic statement-terminator insertion" where that statement-terminator is whatever you want it to be. And to me, that is as form of "semicolon" (which is being used as a generalization for statement-terminator) insertion.