[racket] Problem with case

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Mon Sep 17 19:15:44 EDT 2012

On 9/17/12 7:11 PM, Jon Zeppieri wrote:
> The fact that the first one works at all should probably be considered a
> bug. The syntax of case here:
>
> http://docs.racket-lang.org/reference/case.html?q=case#(form._((lib._racket/private/more-scheme..rkt)._case))
>
> dictates that the constants in a case clause be parenthesized.

But they *are* parenthesized... after the reader expands '.

That's why you can do weird things like ((lambda 'x ''''''x) add1 0).

David

> The more important issue, however, is that the constants are implicitly
> quoted by the case form. So, when you explicitly quote them, they're
> double quoted. You're trying to match 'a against ''a.
>
> -Jon
>
>
> On Mon, Sep 17, 2012 at 6:47 PM, Kieron Hardy <kieron.hardy at gmail.com
> <mailto:kieron.hardy at gmail.com>> wrote:
>
>     Hi all,
>
>     Can anyone explain why the first function below selects 'x1-case as
>     expected but the second fails to select 'x2-case? Am I expecting
>     something to happen that shouldn't?
>
>     Thanks,
>
>     Kieron.
>
>     ****
>
>     #lang racket
>
>     (case 'a
>         ['a 'x1-case]
>         ['b 'x1-case]
>         [(15 2 3) 'y1-case]
>         [(10 11 12) 'z1-case])
>
>     (case 'a
>         [('a 'b) 'x2-case]
>         [(15 2 3) 'y2-case]
>         [(10 11 12) 'z2-case])
>
>
>     ____________________
>        Racket Users list:
>     http://lists.racket-lang.org/users
>
>
>
>
> ____________________
>    Racket Users list:
>    http://lists.racket-lang.org/users
>


Posted on the users mailing list.