'How to use `class-direct-superclasses` and `class-precedence-list` in Steel Bank Common Lisp (SBCL)?
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-listand class-direct-superclasses in SBCL?
Obs.: There is a new version of this tutorial on CLOS via the The Common Lisp Cookbook.
Solution 1:[1]
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>)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
