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

Shared slots, and the generality of WITH-ACCESSORS

I have a couple more questions/suggestions with regard to CLOS
that I'd appreciate comments on.

Is there any clear way to refer to a shared slot of a class even
if an instance of the class is not available, indeed perhaps
before any instance of that class has been made?  The standard
referencing mechanism is SLOT-VALUE, but it requires an instance.
I've heard that the class prototype (if the meta-object protocol
specifies it) can access a shared slot, but does even the class
prototype exist if no actual instance of the class has been made?

It seems that the canonical semantic definition of WITH-ACCESSORS
(via SYMBOL-MACROLET) would accommodate not only a standard class'
slot accessors, but also any monadic function FUNC having a
corresponding (SETF FUNC) function; or even any monadic form FORM
having some corresponding SETF form.  (Of course, the new rules
for SETF guarantee that *every* form FORM has a corresponding SETF
form; the default is (SETF FORM).) This use of WITH-ACCESSORS
would be a useful shorthand, at least for instances of DEFSTRUCT
and in fact for any composite data structure, all the way down to
a CONS.  WITH-ACCESSORS is then no longer CLOS-specific at all,
except for compiler optimizations.  For example:

		(SETF CAR 1)
		(SETF CDR 2)

effectively alters the CAR and CDR of CONS to be 1 and 2,
respectively.  Of course, such usage makes the utility of a
shorthand form of WITH-ACCESSORS (analogous to the short form of
WITH-SLOTS) more obvious.  The shorthand would look like:

		(SETF CAR 1)
		(SETF CDR 2)

Is this at all reasonable?

	Lawrence G. Mayka
	AT&T Bell Laboratories

Standard disclaimer.