1;; 2;; The EVAL function in the original XLISP evaluated in the current lexical 3;; context. This was changed to evaluate in the NIL (global) context to 4;; match Common Lisp. But this created a problem: how do you EVAL an 5;; expression in the current lexical context? 6;; 7;; The answer is you can use the evalhook facility. The evalhook function 8;; will evaluate an expression using an environment given to it as an 9;; argument. But then the problem is "how do you get the current 10;; environment?" Well the getenv macro, below obtains the environment by 11;; using an *evalhook* form. 12;; 13;; The following two macros do the job. Insteading of executing (eval <expr>) 14;; just execute (eval-env <expr>). If you want, you can dispense with the 15;; macros and execute: 16;; 17;;(evalhook <expr> nil nil (let ((*evalhook* (lambda (x env) env))) 18;; (eval nil))) 19;; 20;; Tom Almy 10/91 21;; 22 23(defmacro getenv () 24 '(progv '(*evalhook*) 25 (list #'(lambda (exp env) env)) 26 (eval nil))) 27 28; this didn't work, may be for a later (Almy) version of xlisp? 29;(defmacro getenv () 30; '(let ((*evalhook* (lambda (x env) env))) 31; (eval nil))) ; hook function evaluates by returning 32 ; environment 33 34(defmacro eval-env (arg) ; evaluate in current environment 35 `(evalhook ,arg nil nil (getenv))) 36 37