by otabdeveloper4 · 2y ago · 0 comments
b) When reformatting code like
for a in x:
f(a)
if something:
g()
you're liable to make a typo and commit a grave logic error. for (let a of x) {
f(a);
if (something) {
g();
}
}
If you're a programmer who looks primarily at indentation for their syntax cues, it's the parens that can lead you into traps.So there's arguments either way.
Now that I'm used to it, I do feel that indentation errors (or at least an indentation/paren mismatch) should probably be a syntax error either way.
Possibly people who argue for belts and suspenders might be on to something?
To me, that was a definitive proof that while people may prefer braces over white space the majority of those same people read code, they are using indentation to guide their mental parse tree - not the braces. One obvious reason for doing that is they may not even be able to see the braces in the editor window.
It also seems obvious that the compliers should parse the same way humans do. It makes life so much simpler when we both see the same thing, so the code the compiler is emitting matches the semantic tree we are building in our heads. Which means if your goal is correct, readable code python got it right, and just about every other language gets it wrong. The article notwithstanding, there is not a lot of wriggle on that point.
Whitespace sensitivity is the top of Python’s pretty exhaustive list of flaws.
HCL is fine for this. Editors highlight matching braces, typically, and the parser will typically fail if they are mismatched.