Skip to content
  • Pascal Costanza's avatar
    Added utility function subclassp. · a641d0f0
    Pascal Costanza authored
    Some CLOS implementations have problems with determining subtype relationships between classes in certain corner cases. For example, clisp doesn't like to determine such relationships for forward referenced classes, and some instances of PCL have problems with anonymous classes under certain circumstances (primarily when doing CLOS MOP programming).
    Apparently, subtypep is typically implemented based on the class precedence list, which can only be determined until after a class has been finalized, and this seems to be one of the reasons for these problems. However, the CLOS MOP places restrictions on methods for compute-class-precedence-list such that the subtype relationship actually does _not_ depend on the precedence list, but can be based on a membership test in the unordered set of all direct and indirect superclasses.
    I have provided subclassp in Closer to MOP as a utility function that does just that: It walks the superclass hierarchy to determine whether one class is a subclass of another. This implementation is not that efficient, so it should only be used when subtypep fails. (It could probably be made more efficient, but since this is only provided as a replacement for subtypep in hopefully rare corner cases, I haven't put the energy into this to do this yet.)