In tutorials such as this one, one can simply use:
CL-USER> (class-precedence-list (find-class (class-name (class-of 123))))
In LispWorks they're available via your default package-use-list, in Allegro they're exported from ACLMOP.
But, how to use class-precedence-list
and class-direct-superclasses
in SBCL?
Obs.: There is a new version of this tutorial on CLOS via the The Common Lisp Cookbook.
CodePudding user response:
In SBCL, it is necessary to use package notation importing the symbol from sb-mop
:
CL-USER> (sb-mop:class-direct-superclasses (find-class (class-name (class-of 123))))
(#<BUILT-IN-CLASS COMMON-LISP:INTEGER>)
CL-USER> (sb-mop:class-precedence-list (find-class (class-name (class-of 123))))
(#<BUILT-IN-CLASS COMMON-LISP:FIXNUM> #<BUILT-IN-CLASS COMMON-LISP:INTEGER>
#<BUILT-IN-CLASS COMMON-LISP:RATIONAL> #<BUILT-IN-CLASS COMMON-LISP:REAL>
#<BUILT-IN-CLASS COMMON-LISP:NUMBER> #<SB-PCL:SYSTEM-CLASS COMMON-LISP:T>)