[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Eval



A useful feature of some languages is the ability to evaluate
expressions generated at run-time. For one thing, it means you can use
the implementation language of your program also as a scripting language
to use as its input.

The best support for eval that I know of can be found in some Scheme
implementations. In them, first-class environments allow one to
fine-tune the set of functions that the eval:ed code may access. Perl
and sh also have eval, but I don't think that their semantics is very
clear. Java, along with some other languages, allows run-time _loading_
of (already compiled) code, but that's not quite the same.

What sort of eval support can be found in other languages? I'm not
familiar with Python and Ruby, for example, so I'd like to hear about
them.

Notably, I'm not aware of any statically typed languages with proper
eval support. Haskell's and ML's type systems don't seem to be able to
cope with it. There is a "toplevel" library for O'Caml, though, but its
"eval" only returns a printed representation of a value, not the
evaluated value itself. And again there is no mention of the
environment used.

I'd guess that static typing of eval (and first-class environments)
would require dependent types of some sort. Is anyone aware of languages
that do this? Or even of just basic research on the subject?

Thanks.


Lauri Alanko
la@iki.fi