Given a variable with content 1, I know that it's a member of at least five types:
1 (let* ((fred 1))
2 (princ (typep fred 'bit)) (terpri)
3 (princ (typep fred 'integer)) (terpri)
4 (princ (typep fred 'fixnum)) (terpri)
5 (princ (typep fred 'rational)) (terpri)
6 (princ (typep fred t)) (terpri))
T
T
T
T
T
Two questions here.
Given a variable with arbitrary content, how do I determine its supertype path?
Where could I have found the answer for this in documentation?
Types
You are asking about types, not classes. You cannot expect a good answer to your question because there are far more types which your number
1belongs to than you really care about. E.g.,If you limit your attention to the Standardized Atomic Type Specifiers, you can use something like
Classes
Now, if you are willing to restrict your interest to classes, the situation becomes much more manageable.
First of all, CLOS supports multiple inheritance, so "supertype path" is not uniquely defined a priori.
However, it has to be defined to determine the method precedence order, and this "path" is called class precedence list. It is computed by the standard MOP function
compute-class-precedence-list:which is present in most Common Lisp implementations (use
aproposorfind-all-symbolsto find which package it is exported from).You can use
class-nameto get the names of the classes instead of their metaobjects:Note that
bit,fixnum,unsigned-byte,signed-byte,atomare not in this list because they do not name standard classes, just types.