The specializable
system extends CLOS (the Common Lisp Object
System) and its meta-object protocol with a form of generalized
dispatch by introducing a new generalizer
meta-object.
This system only works in the SBCL Common Lisp implementation.
The specializable system allows meta-programmers to implement new kinds of specializers which can then be used by programmers like this:
(defmethod my-method ((parameter (SPECIALIZER-KIND &rest SPECIALIZER-SYNTAX)))
…)
where SPECIALIZER-KIND
is a symbol designating the new specializer
kind and SPECIALIZER-SYNTAX
is a form which adheres to the
respective syntax and parametrizes the specializer1.
More concretely, assuming a new specializer kind designated by
cl:cons
, the above example would become:
(defmethod my-method ((parameter (cons foo)))
…)
A detailed description can be found in the associated publications 23.
Based on this extension, the following kinds of specializer
s are
provided as seperate ASDF systems:
cons-specializer
for dispatch based on the contents of thecar
slot ofcons
objects. See examples/cons-specializer.lisp.accept-specializer
for dispatch based on HTTP content negotiation. See examples/accept-specializer.lisp.prototype-specializer
for dispatch on prototype objects. See examples/prototype-specializer.lisp
1 While the syntax (SPECIALIZER-KIND &rest SPECIALIZER-SYNTAX)
is the common case and benefits from supporting machinery such
as specializable:define-extended-specializer-syntax
, it is
also possible to define new kinds of specializers with entirely
different syntax. See src/prototype-specializer for an
example.
2 Rhodes, C., Moringen, J., Lichteblau, D.: Generalizers: New Metaobjects for Generalized Dispatch (2014). Available at http://arxiv.org/abs/1403.2765.
3 Newton, J., Rhodes, C.: Custom Specializers in Object-Oriented Lisp (2008). Available at http://www.jucs.org/jucs_14_20/custom_specializers_in_object.