4 ms·
Why is that so much more different from requiring '\n' instead of ';'?
by IcyWindows 2y ago
Why is that so much more different from requiring '\n' instead of ';'?
- gavindean90 2y agoMaybe I like the ‘\n’ for me and the ‘;’ for the compiler.
- xigoi 2y agoThere should be only one source of truth.
- sodapopcan 2y agoBecause when reading as a human you're typing `\n` anyway which fits in with the whole "Can't the computer just figure out what I'm seeing?" thing. While it's technically correct (the best kind of correct) that it's '\n' vs ';', in practice it's really ';' vs ';\n'. I can only speak to my personal experience but seeing two expression on one line is so rare that I can't even think of an example of the last time I saw it.
- masklinn 2y agoThe problem is not two expressions on one line, it’s one expression on two lines. e.g. foo .bar() now you need to either add syntax to specify that you’re “continuing” (python), play tricks for the parser (Go), or have unreliable magic biting you in the ass half the time (javascript).
- deleted 2y ago[deleted]
- sodapopcan 2y agoI understand it's likely stupid in Python since it's whitespace significant, but are those Go parser tricks really such a big deal or even very tricky?
- arp242 2y agoIt's not that difficult; just place the "." at the end of the line: foo. bar() And that will work fine. At least in Go. You can endlessly argue what location is better for the ".", but it really doesn't really matter. Regardless, you don't really need to do parser tricks.
- masklinn 2y agoThat's exactly what I mean by parser trick. You're relying on the idea that if the parser sees an incomplete expression it won't end the statement then and there. It also looks like shit, because now you have to check the end of the previous line to know whether it's a method call or a function call which was indented in incorrectly.
- arp242 2y agoWith gofmt it's always indented correctly.
- sodapopcan 2y agoSure but that doesn't quite answer my question: is the parser trick really that bad? I do see what you mean, of course, and am aware of the arguments but I've never found lack of non-whitespace expression terminator even remotely confusing. I can clearly see indentation in my periphery signalling that it's multi-line. I can also say that in ~13 of using exclusively using semicolon-less languages, I've never had or even heard of a problem caused by someone misunderstanding where an expression ends. Anyway, this is getting pretty bikesheddy, lol but ya, to each their own, obviously.