On 16 Dec 2011, at 16:27, Mark H Weaver wrote: > As an interesting case, suppose that you define the following macro in > module A: > > (define foo 'module-a) > (define-syntax alt-environment > (syntax-rules () > ((_) (the-environment)))) > > and then evaluate the following within module B: > > (define foo 'module-b) > (local-eval 'foo (alt-environment)) > > What should the result be? > > My guess is that it should return 'module-a, because I think > conceptually it should act as though the local-expression passed to > `local-eval' were put in place of (the-environment), wherever that > might be. > > Thoughts?
I thought it should be a way to capture the environment when (the-environment) is evaluated, returning a reference to it. So (define foo 'module-a) (define bar (the-environment)) ; Capture environment, and save reference in bar. Now in (define foo 'module-b) (local-eval 'foo bar) bar refers to the captured environment and 'foo is inserted into that; that is 'module-a. It would need to capture all dynamic syntactic rules as well, otherwise the code cannot be run safely. Hans