[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax checks
From: |
Lynn Winebarger |
Subject: |
Re: Syntax checks |
Date: |
Sat, 13 Apr 2002 13:28:26 -0500 |
On Saturday 13 April 2002 07:48, Neil Jerram wrote:
> I broadly agree with your argument, but have just one question. Does
> this last point mean that macro definitions will only work if they are
> placed _before_ any expressions that use them?
Yes.
> Or am I missing something cleverer here?
Not that I know of. The productions of macro definitions don't get
expanded until the macro is applied so recursive use is fine. Those
productions should (lexically) scope to wherever the macro was defined
(like a module) so that the problem of exporting extra syntax can be
avoided. In some sense this should 'obvious' as macros are just lambdas
and they scope lexically, on the other hand it's not since macros just produce
new code and the evaluator isn't itself scoped to the lexical environment of
the macro. What's the correct evaluation of
(define-syntax foo (syntax-rules () ((_) (bar))))
(define-syntax bar (syntax-rules () ((_) 1)))
(let-syntax ((bar (syntax-rules () ((_) 2))))
(foo))
I'd say it should be 1, even though (foo) produces (bar) in an environment
with a new binding for bar. It should work the same way for modules.
Lynn
Re: Syntax checks, Marius Vollmer, 2002/04/07