[racket] case form implemented with a hash
Hi Hatthew,
I am still trying to implement 'case' by means of a hash.
Can you give me a more specific pointer. I followed your pointer but did not
see anything relevant to my question.
Jos
-----Original Message-----
From: Matthew Flatt [mailto:mflatt at cs.utah.edu]
Sent: miércoles, 28 de septiembre de 2011 22:20
To: Jos Koot
Cc: 'Racket-users'
Subject: Re: [racket] case form implemented with a hash
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'.