[comp.lang.clos] Accessing Class Slots

kamela@pleiades.cps.msu.edu ([Ahmed Mohamed Kamel) (02/26/91)

Does any one know if there is a way in standard CLOS to access the value
of a class-allocated slot given the class (and not an instance of it)?

Please post or e-mail.

All responses are greatly appreciated.

-----------------------------------------------------------------------
Ahmed Kamel				(kamela@cps.msu.edu)
AI/KBS Group
Computer Science Department
Michigan State University

jonl@LUCID.COM (Jon L White) (02/28/91)

re: Does any one know if there is a way in standard CLOS to access the value
    of a class-allocated slot given the class (and not an instance of it)?

The 1988 CLOS spec certainly doesn't provide such a capability, and the
emerging metaobject protocols do not do so either.

However, in the previously-alluded "introspective" subset of the metaobject
protocol I believe there is a function CLOS:CLASS-PROTOTYPE, and you
can use that as a quick way to get an instance without consing up
a fresh one each time.  E.g.,

  (defun shared-slot-value (class slot-name)
    (slot-value (clos:class-prototype class) slot-name))


-- JonL --