3 ms·
> very difficult for python to realize when a line is indented incorrectly. It just assumes that if a line is indented a certain way, it was intentional. How i
by psv1 7y ago
> very difficult for python to realize when a line is indented incorrectly. It just assumes that if a line is indented a certain way, it was intentional.
How is this different from some language not realising that a statement should be inside of the curly brackets instead of outside?
- dreamcompiler 7y agoNo compiler can read your mind. But in a language with brackets, the compiler can at least determine scope even when things are poorly-indented. In Python it can't in a lot of cases. It's like static type checking: The class of errors the compiler can catch is larger when it's present. Likewise, with visible scoping characters, the class of errors the compiler can catch is larger than when they are invisible.
- psv1 7y ago> But in a language with brackets, the compiler can at least determine scope even when things are poorly-indented. Yes, but can it determine scope if things are poorly-bracketed? Because that's the fair comparison.
- smt88 7y agoPoor bracketing almost always causes syntax or compiler errors. As long as you have a language that's block-scoped (which is true of modern JavaScript and most other popular languages), you'll get an error if you make a bracketing mistake. That's not true of indent mistakes. Semantic whitespace is lossy -- there's data contained in those brackets that some people think is low-value that it's expendable for the sake of saving keystrokes, but it does have value in practice.
- fuzz4lyfe 7y agoWith Python, generally speaking, if you are more than a few indentations deep you are doing something wrong. Flat is better than nested
- dreamcompiler 7y agoThat's a good heuristic for a programmer but it's no help to a compiler.