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


    Date: 26 Nov 1986 11:29-EST 
    From: Sean.Engelson at cad.cs.cmu.edu
        Date: Wed, 26 Nov 86 00:24:12 EST
        From: Alan Bawden <Alan at AI.AI.MIT.EDU>
        ...  How do you compile...
    Yes, but given lexical-eval as a special form, you couldn't do that.

Which is exactly why my original message said:

    	    Date: Sat, 22 Nov 86 17:32 EST
    	    From: Alan Bawden <Alan at AI.AI.MIT.EDU>
    	    ...  This demonstrates that LEXICAL-EVAL would have to be a new
    	    special form, rather than simply a function.

    Perhaps lexical-eval could substitute lexical values for the variables
    in its argument, then eval the result?

Perhaps it could use the more or less the same evaluator the interpreter
uses, passing it an environment constructed by the compiler from the
lexically apparent entities surrounding the occurrence of the LEXICAL-EVAL

In painful detail:

(defmacro lexical-eval (foo)
  `(sys:internal-lexical-eval ,foo (sys:the-surrounding-lexical-environment)))

Where SYS:INTERNAL-LEXICAL-EVAL is an ordinary function that is an
implementation dependent entry into the interpreter, and
SYS:THE-SURROUNDING-LEXICAL-ENVIRONMENT is a special form that causes the
compiler to create and return an implementation dependent datastructure
that the interpreter can use to access the variables, block names, tagbody
tags, and macro definitions apparent at that location.

It is -incorrect- that an occurrence of LEXICAL-EVAL hopelessly cripples the
compiler's ability to compile the surrounding code.  A possible expansion

(list (list :read 'x (lambda () x))
      (list :setq 'x (lambda (v) (setq x v)))
      (list :read 'y (lambda () y))
      (list :setq 'y (lambda (v) (setq y v)))
      (list :return-from 'top (lambda (v) (return-from top v)))
      (list :go 'loop (lambda () (go loop))))

where X and Y are the lexically apparent variables, and TOP and LOOP are
the lexically apparent block names and tagbody tags respectively.  This
datastructure would give the interpreter all the access it needs to the
environment in question.  I hope that most Common Lisp compilers can
-already- successfully compile the above expression.

Yes, I have ignored a couple of issues here (like the representation of the
macro definition environment, and the possibility of returning multiple
values from a block), but I don't see any fatal flaws, only complications
that don't belong in a brief message.

I'm still not advocating anything, I'm just trying to make sure we all know
what we are flaming about.