I particularly appreciate that as a billion-dollar mistake, Javascript decided to make it twice (null and undefined).
The question is, what is the order of the mistake. When you have two, is it linear ($2b), quadratic ($1e18), or exponential?
Tony Hoare's Null References: The Billion Dollar Mistake
11–14 of 14 posts
Re: Tony Hoare's Null References: The Billion Dollar Mistake
#12Re: Tony Hoare's Null References: The Billion Dollar Mistake
#13Earlier quoted context omitted.
The simple existence of "Not an object" value is fine. The abstraction built over the raw value should be good enough that it will confront you when you attempt to use it. The next level is constructing types in a way that you can avoid such low level details of whether the pointer is valid. In other words, encode the state in the type instead of a value that you need to test against every time you want to use it.
That's easier said than done, and it's not obvious how to do it with types. Consider a non-blocking read. What the caller does depends on whether the read returns a value or "no data available". If the type of the object returned depends on whether there was a value, you just replaced a null check with a type check. You can avoid that check with a caller with multiple return points and have the callee pick between th…
Re: Tony Hoare's Null References: The Billion Dollar Mistake
#14Earlier quoted context omitted.
That's easier said than done, and it's not obvious how to do it with types. Consider a non-blocking read. What the caller does depends on whether the read returns a value or "no data available". If the type of the object returned depends on whether there was a value, you just replaced a null check with a type check. You can avoid that check with a caller with multiple return points and have the callee pick between th…
Callee can make that decision, it is called the continuation passing style.
There aren't many languages which support multiple continuations and SQL isn't one of them.