On Tue 16 May 2017 23:59, Jan Nieuwenhuizen <[email protected]> writes:
> This code works when not put in a module; make it a module and I get > > => ERROR: Unbound variable: bar I assume you mean that this doesn't work: (define-module (foo) #:export (baz)) (define bar 42) (define (baz) (primitive-eval 'bar)) Then from another module you do (use-modules (foo)) and try to (baz). The thing is that primitive-eval evaluates its expression with respect to the current module. The current module when you do (use-modules (foo)) isn't (foo) -- it's the importing module. This is the right thing: (define-module (foo) #:export (baz)) (define eval-module (current-module) (define bar 42) (define (baz) (eval 'bar eval-module)) Cheers, Andy
