Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created April 19, 2011 15:34
Show Gist options
  • Select an option

  • Save draftcode/928479 to your computer and use it in GitHub Desktop.

Select an option

Save draftcode/928479 to your computer and use it in GitHub Desktop.
(define-syntax l
(syntax-rules ()
((_ P Q ...) (lambda (P) Q ...))))
(define c 1)
(define-syntax macro
(syntax-rules ()
((_ P) ((l c (list c P)) c))))
(let1 c 2 (macro c)) ; => '(1 2)
; This macro expansion is wrong.
; -> ((l c (list c c)) c) => '(2 2)
; To avoid this expansion, we should expand this form as below.
; -> ((l c0 (list c0 c)) 1)
; -> ((lambda (c0) (list c0 c)) 1) => '(1 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment