Template Function - When Code is a Function of Type
In many application domains it is common to implement algorithms that are defined for instances of the common lisp array, sequence and/or number classes. The abstract nature of these classes makes it difficult for compilers to simultaneously satisfy user demands on run-time performance whilst maintaining generality. Unsurprisingly, developers typically sacrifice generality by specializing the implementation to one or more subclasses. This decision introduces issues concerning maintainability, portability and reuse.
The template function system avoids this sacrifice by providing functionality which allows users to request an implementation which is specialized to a set of types. The generated specialization is then associated with a template function object and is automatically selected at runtime or at compile time according to type information found in the function application.
The system provides support for template functions composed of other template functions, recursive template functions, inlined templated functions and template functions accepting optional, rest and keyword arguments. Associated with this functionality is a meta-object protocol consisting of object, glue and syntax layers.
Users should be aware that the interface provided by the template function system is subject to change.
Documentation and tutorials for this project are provided in the project wiki.
Great effort has been spent on implementing this system such that it is portable to all implementations. The compile time dispatch functionality makes extensive use of compiler macros and the CLTL2 environment API.
The template function system can be loaded in to your lisp environment by evaluating the following ASDF forms
The template function system includes a large suite of tests. These tests can be executed by evaluating the following forms
(asdf:test-system "specialization-store") (asdf:test-system "template-function")
- Mark Cox
- Simplified BSD License variant