[racket] Case with strings: normal behavior?

From: Laurent (laurent.orseau at gmail.com)
Date: Mon Nov 19 08:20:20 EST 2012

Oh, thank you all for the (prompt!) reminder, I had forgotten about that.
Match works as expected indeed.


Laurent


On Mon, Nov 19, 2012 at 2:15 PM, Jay McCarthy <jay.mccarthy at gmail.com>wrote:

> case compares with eqv?
>
> strings are only ever eqv? if they are eq?
>
> It turns out that Racket guarantees that all literal strings in your
> program are eq if they have the same letters, so in your program, the
> three "a"s are all the same object.
>
> When you append the empty string to the end, you get a new object, so
> it isn't eqv with the other three.
>
> On Mon, Nov 19, 2012 at 6:07 AM, Laurent <laurent.orseau at gmail.com> wrote:
> > Hi,
> >
> > Is this a bug or a not quite intuitive normal behavior?
> >> (define (foo s)
> >     (case s
> >       [("a") 'a]
> >       [else 'none]))
> >> (foo "a")
> > 'a
> >> (foo (string-append "a" ""))
> > 'none
> >
> > in 5.3.1.5--2012-11-08(5589bcb/a) [3m].
> >
> > Laurent
> >
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121119/fed0b55f/attachment.html>

Posted on the users mailing list.