[R6RS] Internal DEFINE vs. macros

Matthew Flatt mflatt
Wed Apr 13 07:13:20 EDT 2005


At Sat, 09 Apr 2005 15:07:16 +0200, Michael Sperber wrote:
> 
>  (let-syntax ((bar (syntax-rules ()
>                      ((bar) 'outer))))
>    (define first (lambda () (bar)))
>    (define-syntax bar
>      (syntax-rules ()
>        ((bar) 'inner)))
>    (define second (lambda () (bar)))
>    (list (first) (second)))
> 
> It's not immediately obvious what definitions the two invocations of
> BAR refer to---there's at least three possibilities.  PLT and Chez,
> which offer internal DEFINE-SYNTAX, differ:
> 
>   => (inner inner)   ; PLT
>   => (outer outer)   ; Chez

Just to double-check, we've established that this particular difference
is only because of the splicing behavior of Chez's `let-syntax', right?

Adding a `let',

 (let-syntax ((bar (syntax-rules ()
                     ((bar) 'outer))))
   (let () ; <---------------------
     (define first (lambda () (bar)))
     (define-syntax bar
       (syntax-rules ()
	 ((bar) 'inner)))
     (define second (lambda () (bar)))
     (list (first) (second))))

produces '(inner inner) in both Chez and PLT.

Matthew



More information about the R6RS mailing list