[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue MACRO-ENVIRONMENT-EXTENT
> From: sandra%defun@cs.utah.edu (Sandra J Loosemore)
> Date: Sun, 12 Feb 89 19:20:29 MST
>
> Having seen the new proposal for EVAL-WHEN, I still don't have any idea why
> the extent of macro environment objects depends on it. Can you explain the
> connection?
>
> Also, I don't think anybody is arguing for requiring environments to have
> indefinite extent on the grounds that CLOS requires it. (The argument is
> that it's generally useful and for general symmetry with every other kind of
> Lisp data object having indefinite extent.) Just the opposite -- David Gray's
> question was whether that requirement would complicate the implementation of
> CLOS.
The extent of macro environment objects is related to EVAL-WHEN because macro
expanders may wish to return forms which contain environments as quoted
constants. For example:
(defclass position (graphics-object)
((x :accessor position-x :initform 0 :type integer)
(y :accessor position-y :initform 0 :type integer)
(pen-color :allocation :class))
(:default-initargs :screen *position-screen*))
=>
`(progn
(eval-when (compile)
(ensure-class 'position
:metaclass (find-class 'standard-class)
:superclasses (list (find-class 'graphics-object t ',<env>)) ; <= ***
:direct-slots
(list (make-instance 'standard-direct-slot
:name 'x
:initform '0
:readers '(position-x)
:writers '((setf position-x))
:type 'integer)
...
)
:default-initargs
(list (list ':screen '*position-screen* nil))
:environment ',<env>) ; <= ***
)
(ensure-class 'position
:metaclass (find-class 'standard-class)
:superclasses (list (find-class 'graphics-object))
:direct-slots
(list (make-instance 'standard-direct-slot
:name 'x
:initform '0
:initfunction #'(lambda () 0)
:readers '(position-x)
:writers '((setf position-x))
:type 'integer)
...
)
:default-initargs
(list (list ':screen '*position-screen*
#'(lambda () *position-screen*))))
)
Not saying anything about their extent may make such an expansion invalid,
because the expansion might be returned from the dynamic extent of the
environment it points to. Requiring environments to have indefinite extent has
problems for CLOS because at compile-time it wants to create remote metaobjects
and link them into the right places, but then flush those links when the
compilation is over. This is what I am trying to address with my recent
comments about WITH-COMPILATION-UNIT.
kab
-------