[plt-scheme] 'eval' function seems to completely ignore scoping rules.

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jan 18 14:17:12 EST 2008

At Fri, 18 Jan 2008 18:23:17 +0000, "Ran Gutin" wrote:
> That's a bit, how should I say, peculiar?
> The SICP implementation of 'eval' includes a second argument which stores
> the current environment. Is it possible to make this second input implicit?
> And if not that, is it possible to reference the current environment through
> a pointer similar to 'this' or 'self' in OO-land?


I think the main confusion here is that the `eval' procedure that
Scheme gives you is only somewhat related to the `eval' in a Scheme
interpreter's implementation. Historically, they were probably the
same, but I don't know of any production Scheme or Lisp implementation
where they're the same anymore.

The reason is that an interpreter with an `eval' function is only one
way to implement Scheme. In many implementations, there isn't actually
any such value at run-time as the environment argument to an SICP-style
`eval' function. The compiler performs optimizations that, if you
looked at the transformed code as source, would have different
bindings, and the run-time system uses different data structures (e.g.,
a stack).


> On Jan 18, 2008 6:15 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > At Fri, 18 Jan 2008 17:09:15 +0000, "Ran Gutin" wrote:
> > > From what you're saying, it is impossible for MzScheme to parse symbolic
> > > data and produce a value from the local environment.
> >
> > Yes.
> >
> > > Is this unique to PLT Scheme or will I find this same behaviour in other
> > > Scheme / Lisp implementations?
> >
> > You'll find the same behavior in most Scheme implementations.
> >
> > Matthew
> >
> >
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.