[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] need help with hygienic macros
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] need help with hygienic macros |
Date: |
Sun, 12 May 2013 17:24:29 +0200 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, May 12, 2013 at 05:02:46PM +0200, Jörg F. Wittenberger wrote:
> Thanks Peter,
>
> but... it doesn't do the trick for me either.
>
> Nevertheless when I follow your advice and pass _ for the unused outer
> ellipsis, I still end up with the same problem: "foo" is unbound
> in my body...
I have no idea what this macro is attempting to do, but when you
simplify it to the following, you'll see that its expansion doesn't
know about foo:
(define-syntax deftig
(syntax-rules ()
((_ name body ...)
(let-syntax
((pinapple
(syntax-rules <...> ()
((_ ((p v) <...>) bdy <...>)
(let-syntax ((helper (syntax-rules ()
((_ p <...>) '(begin bdy
<...>)))))
(helper v <...>))))))
(pinapple ((foo (x y)) (foog (x y)) (gosh y)) body ...)))))
(deftig bar (foo) (foog 2) (foog 2.5) (let ((n gosh)) (foog n)) 'phar)
=> (begin (foo) (foog 2) (foog 2.5) (let ((n gosh)) (foog n)) (quote phar))
foo really is undefined here. There's no binding construct that
introduces foo, as far as I can tell. That's because "p" is not used
anywhere in the expansion.
In the example, helper is defined as:
(syntax-rules ()
((_ foo bar) (begin body ...)))
and it is invoked as (helper (x y) (x y) body ...)
You really need to expand to something that defines foo if you wish foo
to be visible. There's no hygiene problem I can see: all names are fed
into the macro.
Maybe it would help if you could show us an example invocation and
what it should expand to.
Cheers,
Peter
--
http://www.more-magic.net
Re: [Chicken-users] need help with hygienic macros, Marco Maggi, 2013/05/12