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

Re: hygiene when using multiple instances of a macro..?

This page is part of the web mail archives of SRFI 72 from before July 7th, 2015. The new archives for SRFI 72 contain all messages, not just those from before July 7th, 2015.

On Mon, Aug 08, 2005 at 10:55:51AM -0400, Andre van Tonder wrote:
> >(define-syntax (can-we-stand-duplicates a-macro)
> > (quasisyntax
> >   (if ,a-macro
> >     (let ((x 3)) (,a-macro #f))
> >     x)))
> Thank you for the example, but shouldn't that be instead:
>   (define-syntax (can-we-stand-duplicates a-macro)
>     (quasisyntax
>      (if ',a-macro                     ; note quote
>          (let ((x 3)) (,a-macro #f))
>          x)))

Probably yes, and I'm proud if that was the only mistake I made in using
this facility which I don't thoroughly understand and which I have not
been able to test anywhere :)

I don't understand why the quote is needed, though; and it seems I was
not the only one...

> We do get the right behaviour, since the two x's are created in different 
> /evaluations/ of the quasisyntax form, which suffices to make them 
> different:

Ah, so it's the _expansion_ that creates the new colour for the
(quasi)syntax form.  Great.

Another point that crossed my mind was the difference between

(lambda (form) (quasisyntax (,(cadr form) 'foo 'bar)))
(lambda (form) (quasisyntax ,((cadr form) 'foo 'bar)))

when (cadr form) is a macro; that is, does it make any difference
whether the macro is left for the expander for further expansion or
called directly, reentrantly?

Anyway, thank you for the friendly response.


personal contact: atehwa@xxxxxx, +35841 5323835, +3589 85619369
work contact: panu.kalliokoski@xxxxxxxxxxx, +35850 3678003
kotisivu (henkkoht):	http://www.iki.fi/atehwa/
homepage (technical):	http://sange.fi/~atehwa/