If you do any macro programming in PLT Scheme you are sure
to run into the dreaded “no #%app syntax transformer is bound
” error message at some point. Though puzzling, the fix
is actually quite simple in almost all cases. Assuming
you’re using 3.99, you either need to:
(require (for-syntax scheme/base))
(require (for-template scheme/base))
What the error means is that some syntax has expanded in a
function application, but #%app
, the PLT
Scheme primitive that actually handles application, is not
bound in the phase in which the syntax is being evaluated.
Requiring for-syntax
will bind #%app
in the phase before the current evaluation phase, while
requiring for-template
will bind #%app
in the phase after. In most cases you wantfor-syntax
. However, if you are writing functions that return
syntax that is then inserted into a program (such a
function would be required for-syntax
elsewhere) you must use the other form, to make sure the
syntax has #%app
available to it.