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

Re: [plt-scheme] eval question

Bruce Butterfield wrote:

> An example would be Olin Shiver's embedded awk macro used in scsh; he 
> writes in "A Universal Scripting Framework":
> 	"Whenever necessary, the user can break out of the special-purpose 
> notation and express complex computations in a general-purpose 
> programming language. The Scheme embedding makes simple things easy, and 
> complex things possible..."

This is exactly the kind of use of EVAL that makes people blanch.

As a general rule of thumb, any time a macro uses EVAL directly, the
programmer has misunderstood macros.  Olin's macros do not use EVAL.
I think you would find it instructive to study his code to see how he
gets around the need for eval.

> This is roughly what I had in mind although I could certainly restrict 
> the user code to some arbitrary set of forms that are interpreted with a 
> special-purpose evaluator.

This is even worse.  Unless you have a really good reason for
restricting the language, don't.  And even if you do, try to find a
way to enforce this through something principled like PLT Scheme's
module system.  Don't create an ad hoc evaluator when there's already
a perfectly good one sitting underneath.