[plt-scheme] Re: Using previously-defined macros within the "transformer environment"

From: Noel Welsh (noelwelsh at gmail.com)
Date: Sun Sep 14 09:13:17 EDT 2008

Including the error message would help debug the issue, and including
your code, if it is sufficiently compact, would be good.  Having one
macro expand into another is a fairly standard thing, so I'm surprised
you're having problems.  A trivial example is:

Module a:

#lang scheme/base

(provide a)

(define-syntax a
  (syntax-rules ()
    [(a) (display "a!\n")]))

Module b:

lang scheme/base

(require "a.ss")

(provide b)

(define-syntax b
  (syntax-rules ()
    [(b) (a)]))


> (require "b.ss")
> (b)

A more complex example is define-check in SchemeUnit:


Here, a macro generates a macro which depends on functions defined in
another module.  So this stuff is fairly standard.  Were I writing the
code, I would start by using syntax-rules/syntax-case to define the
base macros, even if the macros they defined were more like defmacro.
The former have more examples, more documentation, and more
safeguards.  Once it was working with syntax-rules/case porting to
define-macro could be done incrementally (though I don't see any value
in doing this).

As an aside, there is no harm in trimming your email replies, nor in
being a bit more polite.


Posted on the users mailing list.