[plt-scheme] eval not aware of vars defined in same function as caller

From: Robby Findler (robby.findler at gmail.com)
Date: Sun Feb 25 15:24:51 EST 2007

The namespace only binds top-level identifiers, not lexical ones. g is
not in the current namespace.

Robby

On 2/25/07, George Herson <gherson at snet.net> wrote:
> (define f 5)
> (define test
>   (lambda ()
>     (define g 4)
>     (display (eval '(* f 3)))(newline)
>     (display (eval '(* g 6)))))
> (test)
> ============>
> 15
> reference to undefined identifier: g
>
> Why is g undefined?  EVAL should be using the current
> namespace, where g /is/ defined.  The "PLT MzScheme:
> Language Manual" says:
> (eval expr [namespace]) evaluates expr in namespace,
> or in the current namespace if namespace is not
> supplied.
>
> The error is the same if I specify (current-namespace)
> in the latter EVAL call.
>
> thank you.
>
> George Herson
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.