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

defmacro environment again..



I'll rephrase the question. Suppose you have the following
in some file:

(let ((a <some-value>))
  (defun a-getter () a)
  (defun a-setter (value) (setq a value)))

It is fairly clear what the compiler should do with this, namely
build a lexical environment when the file is loaded and
create two compiled closures using that environment which define
a-getter and a-setter.

Now suppose we have the following:

(let ((a <some-value>))
   (defmacro hack () `(list 1 2 3 ',a))
   (defun a-setter (value) (setq a value)))

Is the macro HACK allowed to refer to the lexical value of A
which was apparent when the macro function for HACK was
created (loaded)? (I know this is difficult if the macro is used
in the compiler's environment since the compiler does not
have the lexical environment around yet..) ... 

If I read the manual correctly, it is saying that HACK may not
refer to the lexical environment it was defined in. So
my question is, should DEFTYPE,DEFINE-SETF-METHOD and
DEFSETF (complicated version) be the same way?

This is really separate from the &environment arg which
a macro function could use in the runtime environment
to call macroexpand with.

--David