<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- -*- coding:utf-8 -*- -->

  <link rel="icon"          href="/favicon.ico" type="image/x-icon">
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  <link rel="stylesheet"    href="default.css"  type="text/css">
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
  <META NAME="author"             CONTENT="Pascal J. Bourguignon">
  <META HTTP-EQUIV="Description"
        NAME="description"        CONTENT="Graphs of Common Lisp Types">
  <META NAME="keywords"           CONTENT="Graphs, Common Lisp, Types, Graphviz, dot, tred">
  <TITLE>Graphs of Common Lisp Types</TITLE>


<!-- This section is automatically generated by html-update, -->
<!-- from data in 'node.el'.    Please, do not edit it here. -->
<!-- This section is automatically generated by html-update, -->
<!-- from data in 'node.el'.    Please, do not edit it here. -->
 <A CLASS="button" HREF="../../toc.html">Contents</a> |
 <A CLASS="button" HREF="../../index.html">Home</a> |
 <A CLASS="button" HREF="../ffn=-n/index.html">Previous</a> |
 <A CLASS="button" HREF="../usenet.html">Up</a> |
 <A CLASS="button" HREF="../life-saver.html">Next</a> |

<div class="document" id="cl-types">

<h1>Graphs of Common Lisp Types</h1>

<p>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 &amp; dirty program to build those
graphs by introspecting the Common Lisp implementation.</p>

<p>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).</p>

<p>So here is the code of
<a href="cl-types-graph.lisp">cl-types-graph.lisp</a> which gets all the
symbols exported from the COMMON-LISP package, and check their subtype

<p>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.</p>

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

<p>Finally, notice that we only consider here the types denoted by a
single symbol.   The
<a href="http://www.lispworks.com/documentation/HyperSpec/Front/index.htm">
Common Lisp standard</a> actually defines families of types denoted by sexps,
such as <code>(vector 42 single-float)</code>.

<p>The graph thus obtained is written as a <a
href="http://www.graphviz.org/">Graphviz</a> <code>dot</code> file and
graphviz <code>tred</code> and <code>dot</code> are used to generate
the graph image. For example: </p>

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

<p><code>clall</code> can be get from <a href="http://tinyurl.com/2urswh9">here</a> in <a href="http://git.informatimago.com/viewgit/index.php?a=summary&p=public/bin">http://git.informatimago.com/viewgit/index.php?a=summary&amp;p=public/bin</a>.</p>

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


<th>clisp 2.48</th>
<td><a href="cl-types-in-clisp.dot">cl-types-in-clisp.dot</a></td>
<td><a href="cl-types-in-clisp.ps">cl-types-in-clisp.ps</a></td>

<th>Clozure Common Lisp 1.5</th>
<td><a href="cl-types-in-clozure-common-lisp.dot">cl-types-in-clozure-common-lisp.dot</a></td>
<td><a href="cl-types-in-clozure-common-lisp.ps">cl-types-in-clozure-common-lisp.ps</a></td>

<th>ecl 9.12.3</th>
<td><a href="cl-types-in-ecl.dot">cl-types-in-ecl.dot</a></td>
<td><a href="cl-types-in-ecl.ps">cl-types-in-ecl.ps</a></td>

<th>SBCL 1.0.19-gentoo</th>
<td><a href="cl-types-in-sbcl.dot">cl-types-in-sbcl.dot</a></td>
<td><a href="cl-types-in-sbcl.ps">cl-types-in-sbcl.ps</a></td>



<!-- This section is automatically generated by html-update, -->
<!-- from data in 'node.el'.    Please, do not edit it here. -->
 | <a href="http://www.informatimago.com//articles/cl-types/index.html">Mirror on informatimago.com</a>
 | <a href="http://informatimago.free.fr/i//articles/cl-types/index.html">Mirror on free.fr</a>
 | </small></code>

      <a href="http://validator.w3.org/check?uri=referer"><img
          alt="Valid HTML 4.01!" height="31" width="88"></a>