[gambit-list] Using a function in a macro
benjohn at fysh.org
Sat Jun 18 08:11:08 EDT 2011
I think I must not be understanding something basic about macro expansion.
I've reduced a more complex failure with macros that I am having to this simple example:
> ; Define a function.
> (define (inc x) (+ 1 x))
> ;Define a macro using the function.
> (define-macro (macro-inc x) (inc x))
> ; This works okay.
> (define two (inc 1))
> ; This fails on load with:
> ; *** ERROR IN #<procedure #2>, "macro-test.scm"@5.30 -- Unbound variable: inc
> (define macro-two (macro-inc 1))
If I try to load this in to gsc (or if I import in to bsc), then when I try and use (expand) macro-inc (as shown in the last line), I get an error. It's as if I'm not allowed to use functions I have defined in the expansion of a macro?
benjohn at fysh.org - Twitter @benjohnbarnes - Skype benjohnbarnes - Mobile +44 (0) 7968 851 636
More information about the Gambit-list