home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!news.u.washington.edu!uw-beaver!cthomas
- From: cthomas@cs.washington.edu (Christopher Thomas)
- Newsgroups: comp.lang.lisp
- Subject: Evaluating in given environment?
- Message-ID: <1992Nov23.025931.27024@beaver.cs.washington.edu>
- Date: 23 Nov 92 02:59:31 GMT
- Article-I.D.: beaver.1992Nov23.025931.27024
- Sender: news@beaver.cs.washington.edu (USENET News System)
- Distribution: usa
- Organization: University of Washington Computer Science
- Lines: 42
-
-
- I have a problem to solve in Common Lisp, and a solution that seems to work.
- I am posting this to get feedback on the solution.
-
- Problem: I have a macro that takes a form as an argument, and the expansion
- passes that form to a function. I want the function to evaluate the form,
- but in the lexical environment of the macro expansion. Here is a simplified
- example of my problem:
-
- (defmacro eval-it (form &environment env)
- `(function-eval-it ',form ',env))
-
- ... Meanwhile, in another lexical environment...
-
- (defun function-eval-it (form &rest env)
- (evalhook form nil nil env))
-
- (setf x 40)
- (let ((x 10))
- (eval-it (print x)))
-
- 10
- => 10
-
- As I said, this seems to do the right thing, but, I am wondering
- if there is a more elegant way to do this, such as a better way to
- evaluate the form, rather than EVALHOOK. Am I using EVALHOOK properly?
-
- Thanks in advance,
-
- **************************************************************************
- * Christopher Thomas * What do you mean, an African swallow, *
- * Univ. of WA Computer Science * or a European swallow? *
- * cthomas@cs.washington.edu * - King Arthur *
- **************************************************************************
-
-
- --
- **************************************************************************
- * Christopher Thomas * What do you mean, an African swallow, *
- * Univ. of WA Computer Science * or a European swallow? *
- * cthomas@cs.washington.edu * - King Arthur *
-