There is nothing like CLOS which would provide such a feature.
It actually does not fit well into CLOS either. Think about the following, we have the following call of a generic function:
(generic-function-foo 2)
Now we have methods defined for the following types:
(integer 0 9)
(integer 1 9)
(integer 0 99)
(integer 1 99)
(integer -1000 1000)
(or (satisfies evenp) (integer 0 30))
(satisfies evenp)
(satisfies divisible-by-two)
(satisfies all-numbers-which-are-in-my-list-of-numbers)
Which of the methods which all match for 2 should run? If I call CALL-NEXT-METHOD
, which one would be the next?
Now we can say order them by appearance in the source. But in Common Lisp you can add, remove or redefine methods at runtime. The behavior would be more or less random.
We would need some other conflict resolution scheme. For example:
- manually declaring the precedence
- some kind of priority value
- runtime errors with the opportunity for the user to select one
- a type language, which provides an order
- giving up order all together
There have been attempts to provide more expressive dispatch to CLOS. I'm not aware of adding types to CLOS, though. See predicate dispatch and filtered dispatch.
Other than that I would look for a rule-based system, but that usually is very different from CLOS, the Common Lisp Object System, unless it is in some way integrated.