[plt-scheme] Using eval in modules
> On Jun 23, 2007, at 8:56 AM, Jean-Pierre Lozi wrote:
>
> > Hi all,
> >
> > How can I use eval in a module definition? For
> instance,
> >
> > (define (abc x)
> > (display "foo")
> > (newline))
> >
> > ((eval (string->symbol "abc")) 1)
> >
> > works, whereas
> >
> > (module foo mzxcheme
> > (define (abc x)
> > (display "foo")
> > (newline))
> >
> > ((eval (string->symbol "abc")) 1))
> >
> > (require foo)
> >
> > doesn't. Eval appears too look for the abc
> function in the global
> > namespace. Does anyone know a workaround?
> >
> > Thanks,
(eval) wants not just an expression but also an
environment.
(interaction-environment) is the local environment so
far.
(module foo mzscheme
(define (abc x)
(display "foo") (newline))
((eval (string->symbol "abc")
(interaction-environment)) 'ignore))
(require foo)
You will need to understand how environment impacts
the use of eval.
____________________________________________________________________________________
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/