[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
:class slot allocation
- To: tk@hunny.att.com
- Subject: :class slot allocation
- From: Patrick Dussud <dussud@lucid.com>
- Date: Wed, 14 Sep 88 09:42:52 PDT
- Cc: commonloops.pa@Xerox.COM
- In-reply-to: tk@hunny.att.com's message of Tue, 13 Sep 88 16:15:16 EDT <880913-131818-372@Xerox>
- Redistributed: commonloops.pa
Redistributed: commonloops.pa
From: tk@hunny.att.com
Date: Tue, 13 Sep 88 16:15:16 EDT
I've just discovered that :class slot allocation in CLOS isn't what I thought
it was, specifically the meaning of sharing a :class slot among instances of
a class and its subclasses. Evidently shared slots are not shared throughout
the class hierarchy, e.g., given
(defclass foo ()
((baz :allocation :class)))
(defclass bar (foo))
the slot baz is shared among instances of foo, and among instances of bar,
but not among instance of foo and bar; that is, if I change a foo's baz slot,
the baz slot of any instance of bar doesn't change.
This appears to be a bug in PCL. If the slot BAZ is not redefined in bar,
the instances of bar share baz with the instances of foo.
(Refer to the CLOS specs: 88-002R, page 1-12, second paragraph
under "Inheritance of Slots and Slot Options")
The correct way to obtain two shared slots, one for the instances of foo, one
for the instances of bar, is to redefine baz in bar:
(defclass bar (foo)
((baz :allocation :class)))
Patrick.