[racket] Problem with case

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Mon Sep 17 19:14:39 EDT 2012

The reader turns the 'a into (quote a), so you'd actually also get the 'x1-case given 'quote.
I don't think this case is a bug so much as a "gotcha."
----- Original Message -----
From: "Jon Zeppieri" <zeppieri at gmail.com>
To: "Kieron Hardy" <kieron.hardy at gmail.com>
Cc: "users" <users at racket-lang.org>
Sent: Monday, September 17, 2012 7:11:03 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] Problem with case

The fact that the first one works at all should probably be considered a bug. The syntax of case here: 


dictates that the constants in a case clause be parenthesized. 

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. 


On Mon, Sep 17, 2012 at 6:47 PM, Kieron Hardy < 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? 




#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: 

  Racket Users list:

Posted on the users mailing list.