This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Order of syntax macros
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <ctdean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Mon, 10 May 2004 20:31:56 -0700
- Subject: Re: Order of syntax macros
- References: <21556.1084225360@mercedsystems.com>
Chris Dean wrote:
Is it legal to put the definition of a macro after its first use?
Actually, it depends.
is this legal:
(define (foo a) (inc-macro a))
(define-syntax inc-macro
(syntax-rules ()
((inc-macro x) (+ x 1))))
I believe this is allow by the Kawa implementation, though
I don't know what R5RS says about it, and I wouldn't recommend it.
A top-level use of a macro before it is defined is
not allowed by Kawa:
(inc-macro y)
(Actually, it is possible the Kawa implementation happens to
allow it, but that might change.)
This is because Kawa expands top-level forms in the first pass
- it has to since macros may expand to top-level forms.
--
--Per Bothner
per@bothner.com http://per.bothner.com/