[plt-scheme] Eval throwing undefined identifier error

From: Matt Jadud (jadudm at gmail.com)
Date: Sun Nov 11 11:31:02 EST 2007

Hi Jaime,

'eval' is generally a dangerous way to go. I try not to reach for it
unless I am confident there is no other way to write what I need to.

You're running into MzScheme's modules and namespaces. You might find
this cookbook entry helpful:

http://schemecookbook.org/Cookbook/DynamicEvalCustomNamespace

Also, reading in the Help Desk about namespaces would be a good start.
However, I would encourage you to think about why you're using 'eval',
and whether there might be a better solution available to you.

Cheers,
Matt

On Nov 11, 2007 11:18 AM, Jaime Vargas <jev at mac.com> wrote:
> This is probably related to eval and environments. But in the
> following code why is f not available to the eval in module-b. How to
> make it work?
>
> Thanks,
>
> Jaime
>
>
> (module a mzscheme
>    (provide (all-defined))
>    (define (f x) (list x x)))
>
>
> (module b mzscheme
>    (require "a.scm")
>    (define g
>      (let* ((port (open-input-string "`(,(f 1) ,(f 2))"))
>             (input (eval (read port))))
>        (display input))))
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.