Skip to content
Simplification of Common Lisp type specifiers.
Common Lisp
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
code
test-suite
COPYING
README.org

README.org

Simplified Types

Common Lisp has powerful facilities for reasoning about types, including logical connectives, numeric intervals, and predicates involving arbitrary functions. A downside of this expressiveness is that the manipulation of type specifiers is an arduous and error-prone task. This library provides functions to simplify type specifiers.

The API consists of two functions:

  • simplify-type takes a type specifier and, optionally, an environment, and returns the corresponding simplified type.
  • simplified-type-of takes an object and returns the simplified type of that object.

The simplified type hierarchy has been chosen to strike a balance between simplicity and expressiveness. The following simplified type specifiers exist:

  • The symbols t and nil.
  • The symbols function, character, symbol, and cons.
  • The symbols short-float, single-float, double-float, and long-float.
  • The compound type specifier (integer <lower-limit> <upper-limit>), where <lower-limit and <upper-limit> are either an integer, or the symbol *.
  • The compound type specifier (complex <float-type>), where <float-type> is one of the symbols short-float, single-float, double-float, or long-float.

A consequence of restricting all types this way is that the simplified type lattice has only a single layer of disjoint types between t and nil. That means that all types except t and nil are disjoint, that the join of any of these disjoint types is t, and that the meet of any of these disjoint types is nil.

Despite its simplicity, this set of types is expressive enough to help a compiler generate fast code. In particular, it covers all upgraded array element types that are usually provided by an implementation.

The special variable *precise-integer-types* decides whether integer types have a precise upper and lower limit, or whether the simplification may also upgrade the bounds to the symbol *. The advantage of the latter approach is that type simplification will not cons.

You can’t perform that action at this time.