I'm currently trying to assign a variable to macro to store something:
(begin-for-syntax
(define a 0))
(define-syntax (foo stx)
(set! a (+ a 1))
(datum->syntax stx a))
(foo)
(foo)
(foo)
After compiling this piece of code, the repl showed "1 2 3". However, when I entered "(foo)" in the repl, the next number was "1" rather than "4" which was I expected.
1
2
3
> (foo)
1
It looked like the variable "a" was reset after the compiling had done. The same thing happened when I "require" this code in another module.
Is it possible to solve this problem?