View Single Post
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 09-04-2017 , 14:17   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #28

Quote:
Originally Posted by DJ Tsunami View Post
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.
__________________
splewis is offline