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


Can you help me understand some behavior that appears to violate the
Lisp rules governing the order of evaluation of expressions?

I would like to write a function that will compile the current
top-level Lisp expression in a window.  I thought I would make use of
the function ed-eval-or-compile-top-level-sexp, setting the global
variable *compile-definitions* to t beforehand.  But I found that
'beforehand' did not translate into simple sequential ordering of

Since the default value of *compile-definitions* is nil, I wrote the
following to set *compile-definitions* to t, compile the expression,
and set *compile-definitions* back to nil:

	(defun compile-my-function-1 ()
	  (declare (special *compile-definitions*))
	  (setf *compile-definitions* t)
	  (ed-eval-or-compile-top-level-sexp (find-window "my-window"))
	  (setf *compile-definitions* nil))

It didn't work as I thought it should.  The expression in question was
evaluated, not compiled.  It was as if *compile-definitions* was nil
when ed-eval-or-compile-top-level-sexp was evaluated.

Strangely, I could get it to work by removing the statement that reset
*compile-definitions* to nil:

	(defun compile-my-function-2 ()
	  (declare (special *compile-definitions*))
	  (setf *compile-definitions* t)
	  (ed-eval-or-compile-top-level-sexp (find-window "my-window")))

This compiled the expression.  In fact, it didn't matter if I set
*compile-definitions* to t before or after invoking
ed-eval-or-compile-top-level-sexp.  The following worked too, even
if *compile-definitions* was initially nil:

        (defun compile-my-function-3 ()
          (declare (special *compile-definitions*))
          (ed-eval-or-compile-top-level-sexp (find-window "my-window"))
          (setf *compile-definitions* t))

Thanks in advance to anyone who can explain to me why this happens.

- Timur Friedman
M. Timur Friedman (friedman@cs.umass.edu)