[plt-scheme] Using eval in modules

From: Richard Cleis (rcleis at mac.com)
Date: Sat Jun 23 12:21:01 EDT 2007

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070623/5ee9629d/attachment.html>

Posted on the users mailing list.