This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Order of syntax macros


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]