[gambit-list] Syntax visibility in eval (discrepancy between interpreter/compiler behaviour)
Marc Feeley
feeley at iro.umontreal.ca
Thu Apr 19 18:42:34 EDT 2012
On 2012-04-19, at 6:26 PM, Marc Feeley wrote:
> To get your code working in the interpreter and compiler, you should do something like this:
>
> (eval '(load "~~lib/syntax-case"))
> (eval '(define-syntax foo (syntax-rules () ((_) "hi!\n"))))
> (display (eval '(foo)))
Or if you prefer using define-macro, which is more lightweight than define-syntax, you can do:
(define-macro (eval-in-all-environments expr)
(eval expr) ;; in the expansion-time environment
`(begin
(eval ',expr) ;; in the expansion-time environment of the run-time environment
,expr)) ;; in the run-time environment
(eval-in-all-environments
(define-macro (foo) "hi!\n"))
(display (eval '(foo)))
Marc
More information about the Gambit-list
mailing list