schemechicken-schemedefine-syntax

Is it possible to use user defined fuctions when expanding macro?


From chicken scheme manual:

define-syntax evaluates the procedure in a distinct expansion environment (initially having access to the exported identifiers of the scheme module)

Is it possible to inject the user-function to the expansion environment?

(define-syntax my-macro
  (er-macro-transformer
   (lambda (exp rename compare)
     (user-function exp)))

Solution

  • Yes. Use begin-for-syntax or require-extension-for-syntax (the last one also known as use-for-syntax.