In sbcl,
*(sb-mop:class-precedence-list (find-class 'cons))
==>(#<BUILT-IN-CLASS CONS> #<BUILT-IN-CLASS LIST> #<BUILT-IN-CLASS SEQUENCE>
#<BUILT-IN-CLASS T>)
Isn't it stran开发者_如何学Goge that cons inherits from list and not the other way around? What am I missing here?
This is per the specification. A LIST is either a CONS, or a symbol NIL (which is the only object of type NULL), which means that both of those types are specializations of LIST, and hence their equivalent system classes inherit from LIST.
Not all conses are lists (since the ultimate cdr might not be nil), and not all lists are conses (nil is not a list, as mentioned earlier). So technically speaking, neither is of a class that is properly a subclass of the other. I think the spec is written that way because someone saw a practical use, but I agree that it's confusing and it might be misguided.
精彩评论