Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax-rules bug #38

Open
alvatar opened this issue Feb 22, 2012 · 0 comments
Open

syntax-rules bug #38

alvatar opened this issue Feb 22, 2012 · 0 comments

Comments

@alvatar
Copy link
Contributor

alvatar commented Feb 22, 2012

This macro (taken from srfi-67) isn't expanding properly:

(define-syntax if3
  (syntax-rules ()
                ((if3 c less equal greater)
                 (case c
                   ((-1) less)
                   (( 0) equal)
                   (( 1) greater)
                   (else (error "comparison value not in {-1,0,1}"))))))

(define test '(let ((x -1) (y 0)) 
                 (if3 (let ((x0 x)) (set! x (+ x 1)) x0)
                      (begin (set! y (+ y 1))   y)
                      (begin (set! y (+ y 10))  y)
                      (begin (set! y (+ y 100)) y))))

; In REPL:
(expand-macro test)
; =>
(let ((1#x -1) (2#y 0)) (set! 2#y (+ 2#y 1)) 2#y)

; This isn't correct, the expansion should include the case and its clauses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant