[gambit-list] "unbound variable" after importing macro from library
feeley at iro.umontreal.ca
Thu Oct 17 08:42:43 EDT 2019
> On Oct 17, 2019, at 8:14 AM, Lassi Kortela <lassi at lassi.io> wrote:
> With the current master branch of Gambit, given the files:
> ==> foo.scm <==
> (define-macro (hello)
> '(display "Hello world\n"))
> ==> foo.sld <==
> (define-library (foo)
> (export hello)
> (import (scheme base) (gambit))
> (include "foo.scm"))
> The following error occurs:
> $ gsi .
> > (import (foo))
> > (hello)
> *** ERROR IN (stdin)@2.2 -- Unbound variable: foo#hello
> Using ##define-macro instead of define-macro has the same effect, as do `gsi -:r7rs .`, using (load "foo.scm") instead of (import (foo)), and using the compiler instead of the interpreter. However, copy/pasting the define-macro form into the REPL works fine. Exporting procedures (instead of macros) works fine. What is the best current practice for exporting macros?
Currently Gambit’s define-library is compatible with the R7RS define-library and thus supports macros defined with syntax-rules. So this will work:
==> foo.scm <==
((_) (display "Hello world\n"))))
If you want to use macros defined with define-macro, you need to put them in the file foo#.scm and use the primitive modules (i.e. foo.scm and foo#.scm files).
We would like to make the two module systems coexist more seamlessly, so any ideas on how to do that are welcome.
More information about the Gambit-list