3 ms·
Hmm, Aside from the technical aspects, it seems like constructing good error messages involves understanding human ideas of the meaning of programming construc
by joe_the_user 8y ago
Hmm,
Aside from the technical aspects, it seems like constructing good error messages involves understanding human ideas of the meaning of programming constructs.
A big thing is people think of a program as a set meaningful statement with errors involving additions or subtractions from this. But a naive c parser can't give a "missing semicolon" error. All it can do is give "unexpected token X" or some such, because it goes through the code token by token it reaches a token that make sense - that "unexpected token" may be what comes right after the missing semicolon or it might be even further down.
All this is an indication how different the human understanding of a unit of meaning is from just a language spec.
- MauranKilom 8y agoThat doesn't (in theory) prevent a parser from taking a guess what the user meant though, for example by incorporating formatting (that is otherwise irrelevant to the parsing). In C++ terms, a missing a semicolon after a class definition is a problem, but almost always the next token is not on the same line but multiple lines further down if this is what happened. A parser that encounters a class definition followed by one or more newlines and then an unexpected token could very reasonably output a hint that there is probably a missing semicolon here (and possibly continue under the pretense that it was there).
- hinkley 8y agoThe thing that killed my desire to write my own programming language was the stark difference between how I as a human would deconstruct a piece of code that doesn’t compile versus how the tools we tell people to use to build a programming language “accomplish “ the same goal. At the time I gave up for good (never say never?) SGLR was the only strategy one might possibly mistake for “sane”, and it didn’t yet exist in a programming language I wanted to work in.