mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Macro bug


From: Joe Marshall
Subject: Macro bug
Date: Wed, 12 Feb 2020 05:26:12 -0800

Macros don't seem to be hygienic in Release 10.1.10
(define (quux) (display "quux") 'quux)
(define (foo) (display "foo") #f)

(define-syntax or2
  (syntax-rules ()
    ((or2 form1 form2)
     (let ((temp form1))
       (if temp
           temp
           form2)))))

(let ((temp (quux))) (or2 (foo) temp))
quuxfoo
#f  ; Wrong! Should be 'quux

(let ((temp1 (quux))) (or2 (foo) temp1))
quuxfoo
'quux

The binding of temp introduced by the macro is shadowing the binding of temp at the call site in the first example.  The second example shows the expected behavior.

--
~jrm

reply via email to

[Prev in Thread] Current Thread [Next in Thread]