Hacker News new | past | comments | ask | show | jobs | submit login

> Language syntax is redundant so that compilers can detect errors.

Unfortunately, programming language syntax is not as redundant as we would wish. When the code is in the valid syntax, the compiler can parse it. When the code isn't in the valid syntax, the compiler doesn't even have a valid base to parse any information out of the code. The compiler writer may assume a common cause for certain parsing error and insert some "meaningful" error messages, but that is very different from the compiler knows anything. The "redundant" information is carried in the out-of-band channel (human vocabulary and common patterns) rather than in the syntax.




If the code does not match the grammar for the language, that is redundancy in the grammar.

The compiler can (and does, for error messages and error recovery) guess at what was meant, but it cannot know what was meant.


I think you are thinking of "redundant" in terms of information. A syntax does not carry any information on its own. It is a frame for information to reside in.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: