[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EVAL
Date: Sat, 22 Nov 86 17:32 EST
From: Alan Bawden <Alan@AI.AI.MIT.EDU>
Date: Thu, 20 Nov 1986 16:19 EST
From: "Scott E. Fahlman" <Fahlman@C.CS.CMU.EDU>
EVAL cannot easily be defined to work in the lexical environment in
which it appears because that lexical environment is not around at
runtime,....
Right. This demonstrates that LEXICAL-EVAL would have to be a new special
form, rather than simply a function.
This same issue seems to come up over and over. Will someone tell
me what is wrong with the following argument:
I see no reason for "lexical-eval" or any eval with an environment arg.
The following is a trivial source-to-source you can use to get the
effect of a lexical eval:
Suppose you wanted
(defun foo (s-exp)
(let ((x 5))
(flet ((bar (y) (+ x y)))
(block here
(tagbody :there
(lexical-eval s-exp))))))
this is exactly equivalent to:
(defun foo (s-exp)
(eval
`(let ((x 5))
(flet ((bar (y) (+ x y)))
(block here
(tagbody :there
,s-exp))))))
which does not use any "lexical-eval". Since the primary
effect of the compiler is to eliminate lexical environments, any
lexical "stuff" surrounding a call to "lexical-eval" can't really
be compiled (not much anyway) since it all might be referred to
by the s-expression being evaled. This being the case, the
second form here, which just eval's the entire lexical scope,
is roughly as efficient.
...mike beckerle
Gold Hill Computers.