[plt-scheme] Playing with macros

From: Jaime Vargas (jev at mac.com)
Date: Mon Jun 5 12:31:11 EDT 2006

I was playing with macros, and got I bit surprise by the evaluation  
results.
Can some one explain why the first list is printed twice?

(define-syntax probe
   (syntax-rules ()
     ((probe value) (begin
                      (printf "~a=~a~n" (quote value) value)
                      value))))

 > (probe (map + (probe '(1 2 3)) '(4 5 6)))
'(1 2 3)=(1 2 3)
(map + (probe '(1 2 3)) '(4 5 6))=(5 7 9)
'(1 2 3)=(1 2 3)
(5 7 9)
 >

Thx, Jaime


Posted on the users mailing list.