[gambit-list] Syntax visibility in eval (discrepancy between interpreter/compiler behaviour)

Kirill Zorin k.zorin at me.com
Fri Apr 20 11:39:21 EDT 2012


That makes sense. For my purposes I think it'll suffice to simply put all macros in a "macros.ss" file and just load it inside+outside eval in my prelude. Thanks!

On 2012-04-19, at 6:42 PM, Marc Feeley wrote:

> 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