guile-devel
[Top][All Lists]
Advanced

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

Re: define-syntax


From: Neil Jerram
Subject: Re: define-syntax
Date: Tue, 9 Dec 2008 20:20:33 +0000

2008/12/9 Pach Roman (DGS-EC/ESG3) <address@hidden>:
> I've performed following two short tests.
>
> test 1:
> -------
>
> (use-syntax (ice-9 syncase))
>
> (define-syntax my-macro-1
>   (syntax-rules ()
>     ((_ par1 par2 par3)
>      (begin
>            (string-concatenate (list par1 par2 par3))
>            ))))
>
> (define (dummy)
>   (my-macro-1 "a" "b" "c"))
>
> (format #t "dummy => ~s\n" (procedure-source dummy))
>
> result:
> dummy => (lambda () (string-concatenate (list "a" "b" "c")))
>
> test 2:
> -------
> (define-macro (my-macro-2 par1 par2 par3)
>   (string-concatenate (list par1 par2 par3)))
>
> (define (dummy)
>   (my-macro-2 "a" "b" "c")
>   )
> (dummy)
> (format #t "dummy => ~s\n" (procedure-source dummy))
>
> result:
> dummy => (lambda () "abc")
>
> It seems to me the define-syntax is broken in version "1.8.2"
> or I've done something wrong.

These examples both look good to me.  Which one do you think is wrong?

It may help if I point out that define-macro usage usually involves
backquoting.  The define-macro version of your define-syntax example
would normally be:

 (define-macro (my-macro-2 par1 par2 par3)
   `(string-concatenate (list ,par1 ,par2 ,par3)))

Regards,
       Neil




reply via email to

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