The less-familiar parts of Lisp for beginners — subtypep

Our next obscure function is subtypep.  This function allows the program to determine whether one type is a subtype of a second type.  The return values depend on the actual types available in the implementation, as some implementations may not support all available types, and may alias one type to another, in which case they are subtypes of one another.

The subtypep function can also determine whether a class is derived from another class.  All subclasses of a class “C”, even through multiple levels or through multiple inheritance with an unrelated class, are subtypes of class “C”.

This function is somewhat esoteric in its uses.  It can be used to ensure that a passed parameter is of the correct type for the actions that are about to be attempted on it, or in other branching contexts.  Contexts where you might use typecase could possible be amenable to the use of subtypep.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

反垃圾邮件 / Anti-spam question * Time limit is exhausted. Please reload CAPTCHA.