Hacker News new | ask | show | jobs
by kazinator 1072 days ago
There is no difference between "no value" and "the fact that there is no value". "The fact that" is just rhetorical verbiage.

There is an ambiguity in a polymorphic container between a present entry indicating a null value, and a null return indicating there is no entry.

E.g. hash table being used to represent global variables. We'd like to diagnose it when a nonexistent variable is accessed, while allowing access to variables that exist, but have a null value.

This is because the variables are polymorphic and can hold anything.

When we are dealing with a typed situation (all entries are expected to be of a certain type, and null is not a member of that type's domain) then there is no ambiguity: if a null appears in the search for a value that must be a string, it doesn't matter whether "not found" is being represented by an explicit entry with a null value, or absence of an entry.

1 comments

This rhetorical verbiage matters a lot in a language like Lua where you can pack an array full of dbnull sentinel types but filling it with nil results in an empty array.