[plt-scheme] Using eval in modules
This works because you are calling (eval-string-with-1 "abc") from outside
the module - but it doesn't when the function is called from the inside the
module. For instance :
(module foo mzscheme
(define (abc x)
(display "foo")
(newline))
(define (eval-string-with-1 string)
((eval (string->symbol string)) 1))
(eval-string-with-1 "abc")
(provide eval-string-with-1
abc))
(require foo)
Doesn't work. And that's what I need to do :/
On 6/23/07, Richard Cleis <rcleis at mac.com> wrote:
>
> A workaround depends on what you are trying to do. For example, providing
> a function to evaluate a string works, but you also have to provide any
> function you intend to use.
> (module foo mzscheme
> (define (abc x)
> (display "foo")
> (newline))
>
> (define (eval-string-with-1 string)
> ((eval (string->symbol string)) 1))
>
> (provide eval-string-with-1
> abc)
> )
>
> (require foo)
>
> (eval-string-with-1 "abc")
>
> rac
>
>
>
>
> 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,
>
>
> --
> Jean-Pierre Lozi
> http://www.lozi.org
> mailto:jean-pierre at lozi.org
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
>
--
Jean-Pierre Lozi
http://www.lozi.org
mailto:jean-pierre at lozi.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070623/d55e6de4/attachment.html>