[racket] Something funky about the expansion of case?...

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Mar 12 16:53:14 EDT 2012

see evcase 


On Mar 12, 2012, at 4:45 PM, Rüdiger Asche wrote:

> Hi there,
> 
> why is the Zero alias replaced correctly in every form in the expression except the case branch where it is inserted as a literal?
> 
> --------------------------------------------------------------------------------------------
> (require macro-debugger/stepper-text)
> (expand/step-text
> 
> #'(let ()
> 
> (define-syntax alias
>                   (syntax-rules ()
>                    [(_ symbol literal)
>                       (define-syntax symbol (syntax-id-rules () [symbol literal]))
>                    ]))
> 
> 
> (alias Zero 0)
> (alias One 1)
> 
> (letrec (
>              (dummyfn (lambda (c)  ;;
>                                   (case c
>                                       [(Zero)
>                                        One
>                                       ]
>                                    )
>               ))
>       )
>        (if Zero One 2)
>        (if (eqv? '2 Zero) 4 5)
>        (dummyfn Zero)
>  )
> ))
> 
> --------------------------------------------------------------------------------------------
> 
> ==>
> 
> (let-values:1
> ()
> (let-values
> ()
> (letrec-values:37
>  (((dummyfn)
>    (lambda:39
>     (c)
>     (if:40
>      (#%app:41 eqv?:41 c 'Zero)
>      (let-values:40 () '1)
>      (#%app:40 void:40)))))
>  (if '0 '1 (quote 2))
>  (if (#%app:45 eqv? '2 '0) (quote 4) (quote 5))
>  (#%app:47 dummyfn '0))))
> 
> Thanks.
> 
> 
> 
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users



Posted on the users mailing list.