[racket] case form implemented with a hash

From: Jos Koot (jos.koot at telefonica.net)
Date: Wed Sep 28 17:09:12 EDT 2011

I'll study the matter further.
Thanks for your suggestions.
I'll need some time for study, but you can be assured I shall post my
experiences.
Thanks, Jos 

-----Original Message-----
From: Matthew Flatt [mailto:mflatt at cs.utah.edu] 
Sent: miércoles, 28 de septiembre de 2011 22:59
To: Jos Koot
Cc: 'Racket-users'
Subject: RE: [racket] case form implemented with a hash

I had in mind the comment on page 64, bottom right, but I see that it's
a smaller comment than in my memory.

Overall, I think it will work better to use a hash table to go from a
value to an index, and then use a binary search on the index as in
Clinger's paper. Indirect dispatch via thunks in a hash table will most
likely be slower.

At Wed, 28 Sep 2011 22:55:08 +0200, "Jos Koot" wrote:
> 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'.




Posted on the users mailing list.