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

From: Noel Welsh (noelwelsh at gmail.com)
Date: Sun Jan 20 15:59:58 EST 2008

On Jan 20, 2008 3:41 PM, Yavuz Arkun <yarkun at gmail.com> wrote:
> Where (online) can I read more about the background that lead to the
> consensus "eval is not needed", "code doesn't need to equal data", "eval
> can be replaced by X, Y, Z"? And what are the X, Y, Z?

My opinion is this:

One of the major research agendas of programming languages is finding
and formalising commonly repeated code patterns.  For example,
Schemers noticed that writing macros that shadowed identifiers was
often bad, but writing macros that didn't do this was difficult, and
so hygienic macros were invented.  Another example, from the Haskell
world, is the creation of the Applicative functor:
http://www.soi.city.ac.uk/~ross/papers/Applicative.html.  This is good
stuff: it gives structure to code, which makes comprehension easier,
and makes it possible to enforce desirable properties.  It gives
structure to thinking, which drives further research and dissemination
of the ideas, which in turn makes it possible to create more
complicated code by raising the programmer's level of abstraction.

Now eval is just about the opposite of this.  It is completely
unstructured.  It is very difficult to tell what effect uses of eval
will have, and it is hard to enforce other invariants in the presence
of eval.  For these reasons usage of eval is generally discouraged,
particularly as we're now at a fairly advanced state where many uses
of eval have been subsumed by other language features.

However, this does not mean eval is unnecessary.  It still has a
critical use (namely, evaluating code!) that cannot be replaced by
other mechanisms.  For this reason eval is still around, but in a way
that makes its use safer, and perhaps less powerful than the eval of
earlier Lisps/Schemes.


Posted on the users mailing list.