4 ms·
> Syntax errors are more precisely reported, AttributeError/NameError suggest a spelling correction, IndentationError will pinpoint where you screw up... Helpf
by Igelau 5y ago
> Syntax errors are more precisely reported, AttributeError/NameError suggest a spelling correction, IndentationError will pinpoint where you screw up...
Helpful, but I can't help but think of Java's syntax errors when you forget a semicolon. If the compiler knows what you meant, then it knows what you meant. That points to the syntax having extra baggage it doesn't really need.
- BiteCode_dev 5y agoIt doesn't know. You can identify a wrong answer without knowing the right one. I can tell you 1 + '1' is wrong in python, but can't tell what you meant.
- deleted 5y ago[deleted]
- tialaramex 5y agoSometimes it has a pretty good idea. Typo correcting is an excellent example of this. I don't want my program to compile and run if I wrote "taxis" when I meant "taxes". I want an error. Taxis is wrong. But if the diagnostic says "Did you mean taxes?" that's great because it calls attention to the most likely mistake. I'd say if the machine has a suggestion that it knows would work (but could be wrong) it's better to mention what that suggestion is than keep silent, but it would be worse to just press on as if that's what you wrote.