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

Re: COMPUTE-SLOTS in MCL 2.0b1p3?



> Date: Thu, 10 Oct 91 15:48:03 CDT
> From: rodney@hsvaic.boeing.com (Rodney Daughtrey)
> To: info-mcl@cambridge.apple.com
> Subject: COMPUTE-SLOTS in MCL 2.0b1p3?
> 
> What's the best (or any) way to access the names of the slots of some
> class in MCL 2.0b1p3?  COMPUTE-SLOTS, as defined in the MOP, does not
> seem to be defined, although SLOT-DEFINITION-NAME *is* defined, but it
> would need what COMPUTE-SLOTS returned to be of any use.  

Michael Travers answered this question: use CLASS-SLOTS, which
will be called CLASS-INSTANCE-SLOTS in 2.0 final.

> ? (defclass foo () ((bar)))
> #<STANDARD-CLASS FOO>
> ? (describe (find-class 'foo))
> #<STANDARD-CLASS FOO>
> 
> ...stuff deleted...
> 
> DIRECT-SLOTS: (NIL (BAR NIL NIL))
> SLOTS: (NIL . #((BAR NIL NIL)))
>                  ^^^
> I'd like to get to these values, but when I try below...
> 
> ? (slot-value (find-class 'foo) 'slots)
> > Error: #<STANDARD-CLASS FOO> has no slot named SLOTS.
> > While executing: #<STANDARD-METHOD SLOT-MISSING (T T T T)>
> > Type Command-. to abort.
> See the RestartsI menu item for further choices.
> 1 >
> 
> ... I fail (maybe a package problem).  Any ideas?

(slot-value (find-class 'foo) 'ccl::slots) will do what you want. Much
better to use the supported accessor, however, as the slot names are
sure to change when the MOP appears (2.1, I hope).

Someone else pointed out this problem with the inspector, it uses
PRINC for slot names.  The following patch will fix the problem (and
will be part of 2.0 final):

(in-package :inspector)

(defmethod prin1-label ((i inspector) stream value &optional label type)
  (declare (ignore value type))
  (if (stringp label)
    (stream-write-string stream label 0 (length label))
    (princ label stream)))