4 ms·
Y'know I was just musing over this exact feeling myself. I think some languages are more suited to it than others just by their "look". It's just a matter of tr
by kjeetgill 6y ago
Y'know I was just musing over this exact feeling myself. I think some languages are more suited to it than others just by their "look". It's just a matter of trade dress — semicolons just go with curly braces. I find their absence in go jarring too.
- bigyikes 6y agoWhat really keeps me up at night is wondering about the semicolon after a class definition: class Foo { ... };
- regularfry 6y agoThis doesn't get one. It's confusing, but explicit in the ecmascript spec. That form of class definition is called a ClassDeclaration, and they don't take semicolons. I haven't checked, but I think what you've typed here is valid because the parser sees a zero-length expression after the '}'. The reason it's confusing is because if you modify it very slightly, then the semicolon becomes required: let Bar = class Foo { ... }; In that context, precisely the same sequence of characters as you had before is now called a ClassExpression, and the semicolon isn't attached to the class, but instead to the preceding let. I do find semicolons useful as an indicator at the end of the class expression that there's a let or a const somewhere above, but it's far simpler to just not do that and pretend that language facility doesn't exist unless you really, really need it.
- regularfry 6y agoI suspect it is exactly that simple. It's just what we're used to. However I do have a lot of sympathy with the argument (as here) that one shouldn't use an error recovery mechanism for stylistic effect. Automatic semicolon insertion is for fixing mistakes.