Skip to content

markcox80/template-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Installation

The template function system has the following dependencies:

  1. Alexandria
  2. Introspect Environment
  3. Specialization Store
  4. FiveAM (test framework)

The template function system has been tested using SBCL and Clozure Common Lisp.

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

(asdf:load-system "template-function")

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")