Why can't I obtain a simple class-precedence-list in sbcl?
* (sb-mop::class-precedence-list (find-class 'cons));;works
(#<BUILT-IN-CLASS CONS> #<BUILT-IN-CLASS LIST> #<SB-PCL:SYSTEM-CLASS SEQUENCE>
#<SB-PCL:SYSTEM-CLASS T>)
* (defclass my-class () nil)
* (sb-mop::class-precedence-list (find-class 'my-class))
debugger invoked on a UNBOUND-SLOT in thread
#<THREAD "main thread" RUNNING {10039CE8D3}>:
The slot SB-PCL::%CLASS-PRECEDENCE-LIST is unbound in the object
#<STANDARD-CLASS MY-CLASS>.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [USE-VALUE ] Return a value as the slot-value.
1: [STORE-VALUE] Store and return a value as the slot-value.
2: [ABORT ] Exit debugger, returning to top level.
((:METHOD SLOT-UNBOUND (T T T)) #<unavailable argument> #<STANDARD-CLASS MY-CLASS> SB-PCL::%CLASS-PRECEDENCE-LIST) [fast-method]
0] 2
Class finalization
From the MOP description:
Class finalization is the process of computing the information a class inherits from its superclasses and preparing to actually allocate instances of the class. The class finalization process includes computing the class's class precedence list, the full set of slots accessible in instances of the class and the full set of default initialization arguments for the class. These values are associated with the class metaobject and can be accessed by calling the appropriate reader. In addition, the class finalization process makes decisions about how instances of the class will be implemented.
To support forward-referenced superclasses, and to account for the fact that not all classes are actually instantiated, class finalization is not done as part of the initialization of the class metaobject. Instead, finalization is done as a separate protocol, invoked by calling the generic function finalize-inheritance. The exact point at which finalize-inheritance is called depends on the class of the class metaobject; for standard-class it is called sometime after all the classes superclasses are defined, but no later than when the first instance of the class is allocated (by allocate-instance).
The first step of class finalization is computing the class precedence list. Doing this first allows subsequent steps to access the class precedence list. This step is performed by calling the generic function compute-class-precedence-list. The value returned from this call is associated with the class metaobject and can be accessed by calling the class-precedence-list generic function.
...
Example
* (defclass my-class () nil)
#<STANDARD-CLASS MY-CLASS>
* (sb-mop:class-finalized-p (find-class 'my-class))
NIL
* (sb-mop:finalize-inheritance (find-class 'my-class))
NIL
* (sb-mop:class-finalized-p (find-class 'my-class))
T
* (sb-mop:class-precedence-list (find-class 'my-class))
(#<STANDARD-CLASS MY-CLASS> #<STANDARD-CLASS STANDARD-OBJECT>
#<SB-PCL::SLOT-CLASS SB-PCL::SLOT-OBJECT> #<SB-PCL:SYSTEM-CLASS T>)