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

:class slot allocation

   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)))