[plt-scheme] hash-has-key?

From: Sam TH (samth at ccs.neu.edu)
Date: Sat Mar 28 12:15:59 EDT 2009

On Sat, Mar 28, 2009 at 3:43 PM, Thomas Chust <chust at web.de> wrote:
> In the same vein you could generate unwrapping code that throws an
> exception if a "not found" value is encountered and strips the wrapper
> otherwise for code like
>  (let: ([v : ValueType (hash-ref ht some-key)])
>    ...)
> but not for something like
>  (let: ([v : Any (hash-ref ht some-key)])
>    ...)

This does not help at all.  Imagine that the 'not-found-value' is
called QQQ.  Then we have two choices:

- QQQ is a value in our language.  Then it can be stored in the hash,
and we can't tell if we need to throw an exception.  This is the
current situation.

- QQQ is not a value in our language.  Then what is it?  Note that
hash tables can no longer be implemented without compiler support,
because they have to know about QQQ, the magical non-value.  And if
it's not a value, how could be bind it to `v' in your second example?

sam th
samth at ccs.neu.edu

Posted on the users mailing list.