At the moment, hashmap[val] return fail when val is not in hashmap. This is inconsistent with lists, where l[2] returns an error if 2 is not bound in a list l.
My suggested fix:
-
Make hashmap[val] return an Error if val is unbound.
-
Add a new function Lookup(map, key [,default]), which returns map[key] if that is defined, and default otherwise. If default is ommitted, treat it as fail, which gives the behaviour of the current hashmap[val].
At the moment,
hashmap[val]returnfailwhenvalis not in hashmap. This is inconsistent with lists, wherel[2]returns an error if2is not bound in a listl.My suggested fix:
Make
hashmap[val]return an Error if val is unbound.Add a new function
Lookup(map, key [,default]), which returnsmap[key]if that is defined, anddefaultotherwise. If default is ommitted, treat it asfail, which gives the behaviour of the currenthashmap[val].