Illegal vs Unwanted States

24 points by ajdecon


hmpc

This distinction comes up a lot in parsing scenarios. For example, robust interfaces rarely if ever parse integers as unsigned even if negative numbers are not allowed, as that would make it impossible to detect and adequately signal the error to the user. Similarly, compilers have to be able to represent illegal syntax in order to produce good error messages, which introduces a not insignificant amount of complexity to the design.

It's also one of the big reasons prototypes can be hard to iterate into real products, as we have likely already chosen a state representation which makes it easier to implement the happy paths but impossible to handle deviations. Starting from scratch with a more complete state machine in mind is often faster and more reliable.