From: Jim Newton
Subject: nothing left for make-instances-obsolete to do
Date:
Message-ID: <47fcc620$1@news.cadence.com>
Hi CLOS experts, i'm confused about make-instances-obsolete!
Can someone please explain to me what the method for
make-instances-obsolete on standard-class
is supposed/expected to do. Is it really required to do anything
in the (usual) case that instances are updated lazily.
I'd potentially like/expect make-instances-obsolete to somehow
mark the old "version" of the class as being obsolete so
that subsequent slot references slot-value-using-class
and (setf slot-value-using-class) can figure out that
the instance is obsolete and it can call
update-instance-for-redefined-class.
However, the old "version" of the class i not actually passed
to make-instances-obsolete. I'm not 100% sure about this, but
the spec says that make-instances-obsolete is called AFTER it has been
determined that slots have been added or discarded or the storage
order of slots has change.
It cannot know this unless it has
already computed the new slots which is most of the work of
re-initializing the class. Is ensure-class supposed to figure this
out, then call make-instances-obsolete who must figure it out all over
again?
I cannot see anything useful for make-instances-obsolete to do
except serve as a place for methods more specific than that
of standard-class to be attached.
-jim
--
+------------------------------------------------------------------------+
| Jim E. Newton (·····@cadence.com) desk +49-(0)89-4563-1918 |
| Methodology Services Europe fax +49-(0)89-4563-1819 |
| Cadence Design Systems GmbH Munich Germany |
| |
| If you won't do it in the rain, you won't do it. |
+------------------------------------------------------------------------+
Jim Newton wrote:
> Hi CLOS experts, i'm confused about make-instances-obsolete!
>
> Can someone please explain to me what the method for
> make-instances-obsolete on standard-class
> is supposed/expected to do. Is it really required to do anything
> in the (usual) case that instances are updated lazily.
The idea is that make-instance-obsolete does exactly that: Mark the
instances which are not updated yet such that they can be updated later.
(It's typically implemented by marking the updated class metaobject.)
> I cannot see anything useful for make-instances-obsolete to do
> except serve as a place for methods more specific than that
> of standard-class to be attached.
Make-instances-obsolete is a hook for the triggering the update of such
instances. The usual advantages are: You can define methods on
make-instances-obsolete, such that you know that this is happening, and
can take special action for your own classes on top of that (update some
views, or so). Because of the CLOS MO, this is not that useful anymore,
because you can also define methods on reinitialize-instance or
finalize-inheritance for that purpose, but make-instances-obsolete is a
bit more fine-grained because it is only called when the slot layout
actually changes.
The second advantage is that you can call make-instances-obsolete
yourself to trigger that based on other criteria than what ANSI Common
Lisp specifies. For example, I do this in one of my ContextL
metaclasses, because I indeed have an additional criterion when objects
should be updated.
Pascal
--
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/