[racket] case form implemented with a hash

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Sep 28 16:19:44 EDT 2011

At Wed, 28 Sep 2011 22:08:44 +0200, "Jos Koot" wrote:
> By inspection with the macro stepper I found that case forms are expanded to
> nested if-forms. For case forms with many clauses, this may be inefficient.
> I have tried to prepare a hash-case form using a hash table in order to
> select the desired clause more efficiently. So far my attempts failed. I am
> still trying. However, has anybody else on this list thought of using a hash
> for case forms with many clauses? Does it exist? If not, would anyone be
> interested in a hash-case form that has the same shape as a case-form, but
> uses a hash-table to select the appropriate clause? The hash table should be
> a map onto thunks and macro hash-case simply would have to retrieve the
> thunk and call it.

See "Rapid Case Dispatch in Scheme", Clinger, Scheme'06.

If you implement a revised `case' that consistently works better, then
I'd be happy to use it as a replacement for the current `case'.

Posted on the users mailing list.