[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (match ...) error inside (define-syntax ...)
From: |
Andy Wingo |
Subject: |
Re: (match ...) error inside (define-syntax ...) |
Date: |
Tue, 15 Jun 2010 23:10:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) |
Hi,
On Tue 15 Jun 2010 11:53, Tentaclius <address@hidden> writes:
> (define-syntax test
> (syntax-rules ()
> ((test)
> (lambda args
> (match args
Guile's match implementation implemented using define-macro, so it is
not hygienic. `args' is produced by the expansion of a hygienic macro,
so the expansion of `match' can't see it.
>From NEWS:
** Lexical bindings introduced by hygienic macros may not be referenced
by nonhygienic macros.
If a lexical binding is introduced by a hygienic macro, it may not be
referenced by a nonhygienic macro. For example, this works:
(let ()
(define-macro (bind-x val body)
`(let ((x ,val)) ,body))
(define-macro (ref x)
x)
(bind-x 10 (ref x)))
But this does not:
(let ()
(define-syntax bind-x
(syntax-rules ()
((_ val body) (let ((x val)) body))))
(define-macro (ref x)
x)
(bind-x 10 (ref x)))
It is not normal to run into this situation with existing code. However,
as code is ported over from defmacros to syntax-case, it is possible to
run into situations like this. In the future, Guile will probably port
its `while' macro to syntax-case, which makes this issue one to know
about.
In short: use something other than `match', or contribute a hygienic
implementation of `match' :)
Cheers,
Andy
--
http://wingolog.org/