Graphs of Common Lisp Types

A newbie asked about the types defined in Common Lisp. There was a nice graph of Common Lisp types published some times, but despite my google-foo, I couldn't find it again. It's not the first time. So I decided to write a little quick & dirty program to build those graphs by introspecting the Common Lisp implementation.

Notice that the graph of type hierarchy depends on the implementation, because some type relationships are left to the implementations to be defined (eg. the subtypes of FLOAT may all be the same, or all distinct, or some combination as long as some order on the significant bits they have).

So here is the code of cl-types-graph.lisp which gets all the symbols exported from the COMMON-LISP package, and check their subtype relationships.

In the case of some implementations such as Clozure or SBCL, any symbol denotes a type, so is integrated to the graph, between the NIL and T types. This is not meaningful, so we remove them.

Equivalent type names are drawn in a single box labelled by a list containing all the equivalent type names.

Finally, notice that we only consider here the types denoted by a single symbol. The Common Lisp standard actually defines families of types denoted by sexps, such as (vector 42 single-float).

The graph thus obtained is written as a Graphviz dot file and graphviz tred and dot are used to generate the graph image. For example:

    clall '(load "cl-types-graph.lisp")'
    for f in cl-types-in-*.dot ; do
       tred < $f |dot -Tps /dev/stdin > ${f/.dot/.ps}
    for f in  cl-types-in-*.ps ; do
       gsview $f &

clall can be get from here in

Finally, you can get the generated graphs to compare the type hierarchy of these various implementations:

clisp 2.48
Clozure Common Lisp 1.5
ecl 9.12.3
SBCL 1.0.19-gentoo

| Mirror on | Mirror on |
Valid HTML 4.01!