Quote:
Originally Posted by DJ Tsunami
I'm not sure what's considered "programmer error" in this case. If you pass an invalid index to an ADT array it throws an error, but if you pass an invalid key to an ADT trie it returns false. So the former is programmer error, but the latter is not?
|
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.
Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.
Even without that the lack of a "key existence check", most languages don't let you index to random parts of dynamic arrays (exception / undefined behavior), but most will let you attempt lookups to non-existent keys in maps.
__________________