[racket] Case with strings: normal behavior?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Nov 20 08:42:46 EST 2012

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.


Posted on the users mailing list.