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

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



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)))
and
(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.

Panu

-- 
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/