[plt-scheme] hash-has-key?

From: Dave Herman (dherman at ccs.neu.edu)
Date: Sat Mar 28 10:07:50 EDT 2009

Robby Findler:
> There seems to be compounding confusion here ....


>>> Because Scheme is untyped, it's not possible for hash-ref to  
>>> return one
>>> standard "not found" value, so the API ought to provide a predicate.
> I'm not sure what this means. hash-ref accepts a thunk to call in the
> case the result isn't found.

Yes, certainly. My point wasn't deep, just that it isn't possible to  
create a collection API that returns a special "not found" value  
without the possibility of someone actually storing the "not found"  
value in the collection-- in which case there's an ambiguity between  
"not found" and "found the 'not found' value". The thunk  
disambiguates, but places the responsibility on the client to decide  
what value to use (or effect to generate) to disambiguate.

I realize that the "untyped" aspect was a red herring; what in ML/ 
Haskell would be implemented with an option type could of course also  
be done in the untyped setting by having hash-ref return e.g. either  
(make-SOME v) or #f. But that's not the way hash-ref works.

That said...

Matthias Felleisen:
> Because Typed Scheme is typed, it's not possible for hash-ref to use  
> one standard "not found" type, so the API ought to provide the  
> return type.

I don't know what this means.


Posted on the users mailing list.