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

From: Rüdiger Asche (rac at ruediger-asche.de)
Date: Mon Mar 12 16:45:45 EDT 2012

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.




Posted on the users mailing list.