In Guile scheme, I have a macro which calls another macro, and I want the call to the inner macro to reference a symbol used in the inner macro. Here is a simple example to illustrate the kind of thing I'm trying to acheive:
(define-syntax macro1
(lambda (x)
(syntax-case x ()
((macro1 expr1)
(with-syntax ((f (datum->syntax x 'f)))
#'(lambda (f) expr1))))))
(define-syntax macro2 (lambda (x)
(syntax-case x ()
((macro2 expr2)
#'(macro1 (expr2 f))))))
((macro2 1+) 2)
I expected the final line to return 3, but instead I got the following error:
;;; <stdin>:142:0: warning: possibly unbound variable `f'
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Unbound variable: f
Is it possible to do what I want?