[racket] Case with strings: normal behavior?

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Tue Nov 20 09:15:04 EST 2012

On Tue, Nov 20, 2012 at 07:42:46AM -0600, Robby Findler wrote:
> On Tue, Nov 20, 2012 at 12:14 AM, David T. Pierson <dtp at mindstory.com> wrote:
> > On Mon, Nov 19, 2012 at 06:13:09AM -0700, Matthew Flatt wrote:
> >> Should we change `case' to use `equal?' instead of `eqv?'? I can't
> >> think of a good reason to stick with `eqv?'.
> >
> > My first reaction to this was that such a change would eliminate one of
> > the motivations for using `case': getting the (perhaps insignificant?)
> > performance improvement of using `eqv?' in a conditional when you know
> > the key type is suitable for it.
> >
> > However it occurs to me that since the datums in a `case' clause are
> > always literals, couldn't the expansion of `case' be "smart" enough to
> > use the appropriate comparison function (eq?/eqv?/equal?) given the type
> > of the datum?
> 
> I think that equal? will always terminate quickly when its input is a
> symbol/number/boolean so the macro doesn't need to do anything special
> in that case.

It could do a binary tree search on the data and use some kind of 
ordering comnparison.

By the way, it's a long time since I saw 'datums' as plural of 'datum'.
I wonder if it will become correct one of these years, since 'data' is 
often misused as singular, as a substance noun instead of an object 
noun. 

-- hendrik

Posted on the users mailing list.