[plt-scheme] Using eval in modules

From: John Clements (clements at brinckerhoff.org)
Date: Sat Jun 23 12:42:39 EDT 2007

On Jun 23, 2007, at 9:31 AM, Jean-Pierre Lozi wrote:

> 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 :/

Modules are designed to be separately compiled, and generally (as I  
understand it) to discourage the kind of dynamic interaction allowed  
by "eval." For instance, the presence of eval in a module in the way  
you describe would make it impossible for a compiler to conclude that  
a module binding is never mutated.  If you allow uses of eval to  
modify syntactic bindings, things get even weirder. Would it be  
presumptuous to ask what the intended application is, and whether  
there's another way to accomplish it?

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2223 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20070623/457b7124/attachment.p7s>

Posted on the users mailing list.