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}
    done
    for f in  cl-types-in-*.ps ; do
       gsview $f &
    done

clall can be get from here in http://git.informatimago.com/viewgit/index.php?a=summary&p=public/bin.

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

clisp 2.48 cl-types-in-clisp.dot cl-types-in-clisp.ps
Clozure Common Lisp 1.5 cl-types-in-clozure-common-lisp.dot cl-types-in-clozure-common-lisp.ps
ecl 9.12.3 cl-types-in-ecl.dot cl-types-in-ecl.ps
SBCL 1.0.19-gentoo cl-types-in-sbcl.dot cl-types-in-sbcl.ps

| Mirror on informatimago.com | Mirror on free.fr |
Valid HTML 4.01!