improve expansion of 'case' for a clause with 2 or 3 values

svn: r15428
This commit is contained in:
Matthew Flatt 2009-07-11 04:03:20 +00:00
parent ec9ce0ed04
commit b2e39baa26

View File

@ -9,10 +9,13 @@
(define-syntax case-test
(lambda (x)
(syntax-case x ()
;; For up to 3 elements, inline `eqv?' tests:
[(_ x (k))
(if (symbol? (syntax-e #'k))
(syntax (eq? x 'k))
(syntax (eqv? x 'k)))]
(syntax (eqv? x 'k))]
[(_ x (k1 k2))
(syntax (let ([tmp x]) (if (eqv? x 'k1) #t (eqv? x 'k2))))]
[(_ x (k1 k2 k3))
(syntax (let ([tmp x]) (if (eqv? x 'k1) #t (if (eqv? x 'k2) #t (eqv? x 'k3)))))]
[(_ x (k ...))
(syntax (memv x '(k ...)))])))