Commit ca622c4d authored by Marco Antoniotti's avatar Marco Antoniotti

Updated .gitiginore and removed tracking of 'docs' folder.

parent 8ee554e6
......@@ -5,4 +5,5 @@
THUM*.DBE
docs/*html*/*
docs/
dbdb.lisp
<html>
<head>
<title>CL Control Flow</title>
<link rel="stylesheet" href="main.css">
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" bgcolor="#ffffff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" vspace="0" hspace="0">
<tr>
<td colspan="3">
<div class="header"
style="font-family:=Verdana,Arial,Helvetica; font-size: 18px; color: #41286f;">
<strong><i>CL Extensions: CONTROL FLOW</i><string>
<div class="navigation">
<a href="index.html" class="navigation-link-selected">Home</a>
| <a href="downloads.html" class="navigation-link">Downloads</a>
| <a href="links.html" class="navigation-link">Links</a>
</div>
</div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
<div class="middle-bar"><img src="images/shim.gif" height="5" width="1"></div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
</td>
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<h1>Control Flow</h1>
<p>In order to make the use of the UNIFICATION library easier, a few
utility macros are provided. The macros MATCH, MATCHING, and
MATCH-CASE can be used to unify two (or more) objects and then to
build a lexical environment where the variables present in the to
objects (or templates) are bound to the values resulting from the
application of UNIFY.</p>
<p>
<ul>
<li>MATCH is a "single shot" macro. It does one unification and
executes forms in an appropriate lexical environment.</li>
<li>MATCH-CASE is equivalent to CASE. It tries to match a single
object (or template) against a set of clauses. The forms associated
to the first clause for which there is a successful unification, are
then executed within an appropriate lexical environment.</li>
<li>MATCHING is equivalent to COND. Each clause contains a
<em>head</em> consisting of two objects to be unified. The first
clause whose head unifies sucessfully has its associated forms
executed within an appropriate lexical environment.</li>
</ul>
</p>
<p>There are also the macro MATCHF and MATCHF-CASE, which do not
evaluate the pattern; they can be used to produce more streamlined
code.</p>
<h1>Examples</h1>
<p>These macros allow the construction of interesting <em>pattern
matching</em> like code.</p>
<p>
<pre>
(defun factorial (x)
(<b>match-case</b> (x)
(0 1)
(#T(number ?n) (* ?n (factorial (1- ?n))))
(otherwise (error "Incorrect match for ~S." x))))
</pre>
</p>
<p>Or consider the more interesting piece of code from a not-so
hypothetical Red-Black tree implementation (<em>cfr.</em>&nbsp;[<a
href="#O98">O98</a>].) The function BALANCE is the key part of the
rebalancing act played by Red-Black trees.</p>
<p>
<pre>
(defstruct (tree-node (:conc-name tn-)
(:constructor mk-tn (color left elem right)))
color
left
elem
right)
(defun balance (&rest balancing-arguments)
(<b>match-case</b> (balancing-arguments)
((:black #T(tree-node tn-color :red
tn-left #T(tree-node tn-color :red
tn-left ?a
tn-elem ?x
tn-right ?b)
tn-elem ?y
tn-right ?c)
?z
?d)
(mk-tn :red (mk-tn :black ?a ?x ?b) ?y (mk-tn :black ?c ?z ?d)))
((:black #T(tree-node tn-color :red
tn-left ?a
tn-elem ?x
tn-right #T(tree-node tn-color :red
tn-left ?b
tn-elem ?y
tn-right ?c))
?z
?d)
(mk-tn :red (mk-tn :black ?a ?x ?b) ?y (mk-tn :black ?c ?z ?d)))
((:black ?a
?x
#T(tree-node tn-color :red
tn-left #T(tree-node tn-color :red
tn-left ?b
tn-elem ?y
tn-right ?c)
tn-elem ?z
tn-right ?d))
(mk-tn :red (mk-tn :black ?a ?x ?b) ?y (mk-tn :black ?c ?z ?d)))
((:black ?a
?x
#T(tree-node tn-color :red
tn-left ?b
tn-elem ?y
tn-left #T(tree-node tn-color :red
tn-left ?c
tn-elem ?z
tn-right ?d)))
(mk-tn :red (mk-tn :black ?a ?x ?b) ?y (mk-tn :black ?c ?z ?d)))
((?color ?left ?elem ?right)
(mk-tn ?color ?left ?elem ?right))))
</pre>
</p>
<p>This version of BALANCE is more verbose than the one given in [<a
href="#O98">O98</a>], but it preserves the general elegance of the
ML implementation.</p>
<h1>Control Flow Dictionary</h1>
<ul>
<li><a href="match-macro.html"><i>Macros</i> <b>MATCH</b> and <b>MATCHF</b></a>
<li><a href="match-case-macro.html"><i>Macros</i> <b>MATCH-CASE</b>
and <b>MATCHF-CASE</b></a>
<li><a href="matching-macro.html"><i>Macro</i> <b>MATCHING</b></a>
</ul>
<h1>Notes</h1>
<h2>Other Forms</h2>
<p>It would be obvious to add the macros EMATCH-CASE and
CMATCH-CASE, for symmetry with ECASE and CCASE. Also, MATCHING
could be renamed to MATCH-COND.</p>
<h2>Current Implementation Details</h2>
<p>The current implementations of MATCHING and MATCH-CASE do not
handle user supplied environments yet.</p>
<h2>References</h2>
<p>
<a name="O98">[O98]</a> C. Okasaki, <i>Purely Functional Data
Structures</i>, Cambridge University Press, 1998.
<!--
;;; Copyright (c) 2004-2013 Marco Antoniotti, All rigths reserved.
;;;
;;; Permission to use, modify, and redistribute this code is hereby
;;; granted.
;;; The code is provided AS IS with NO warranty whatsoever. The author
;;; will not be held liable etc etc etc etc etc.
-->
<!--
<h2>Site Map</h2>
<p>Enjoy!</p>
<hr>
<p>Questions? Queries? Suggestions? Comments? Please direct them
at <a href="mailto:marcoxa_PROVA_A_SPAMMARME@alu.org">me</a>.
</p>
-->
</div>
</div>
</td>
<!-- <td height="100%">&nbsp;</td> -->
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<!-- <h1>News</h1>
<p>News in chronological order, most recent on top.
</p>
<ul>
<li><strong>2004-10-30</strong><br>
Document created
</li>
</ul>
-->
</div>
</div>
</td>
<td height="100%">&nbsp;</td>
</tr>
<tr>
<td colspan="3" valign="bottom" align="right">
<div class="copyright">
&copy; 2003-2013, Marco Antoniotti, all rights reserved.
</div>
</td>
</tr>
</table>
</body>
</html>
This diff is collapsed.
<html>
<head>
<title>CL Unification: Class AREF-TEMPLATE</title>
<link rel="stylesheet" href="../main.css">
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" bgcolor="#ffffff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" vspace="0" hspace="0">
<tr>
<td colspan="3">
<div class="header"
style="font-family:=Verdana,Arial,Helvetica; font-size: 18px; color: #41286f;">
<strong><i>CL Unification: Class AREF-TEMPLATE</title></i></strong>
<div class="navigation">
<a href="index.html" class="navigation-link">Home</a>
| <a href="../unification-dictionary.html" class="navigation-link">Dictionary</a>
| <a href="element-template-class.html" class="navigation-link">Previous</a>
| <a href="elt-template-class.html" class="navigation-link">Next</a>
| <a href="downloads.html" class="navigation-link">Downloads</a>
| <a href="links.html" class="navigation-link">Links</a>
</div>
</div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
<div class="middle-bar"><img src="images/shim.gif" height="5" width="1"></div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
</td>
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<h1><i>Class</i> <strong>AREF-TEMPLATE</strong></h1>
<h2>Package:</h2>
<p><code>COMMON-LISP.EXTENSIONS.DATA-AND-CONTROL-FLOW.UNIFICATION</code></p>
<h2>Class Precedence List:</h2>
<p>
AREF-TEMPLATE, ELEMENT-TEMPLATE, EXPRESSION-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.
</p>
<h2>Known Subclasses:</h2>
<p>
None.
</p>
<h2>Slots:</h2>
<p>None.</p>
<h2>Description:</h2>
<p>The AREF-TEMPLATE class denotes those object that are used
to unify against a particular element of an ARRAY.</p>
<h3>Template Syntax:</h3>
<p>
<pre>
#T(<b>aref</b> (<i>index1</i> ... <i>indexN</i>) <i>item</i>)
</pre>
</p>
<p>
<pre>
#T(<b>aref</b> <i>index</i> <i>item</i>)
</pre>
</p>
<p>The AREF-TEMPLATE syntax denotes the <i>item</i> at
<i>index1</i> ... <i>indexN</i> of an ARRAY. An AREF-TEMPLATE must
be unified against a ARRAY object. <i>item</i> is <em>unified</em>
against the element extracted from the sequence object at
<i>index1</i> ... <i>indexN</i> by the standard function AREF.</p>
<p>The second form is a shorthand.</p>
<p>
<pre>
#T(<b>aref</b> <i>index</i> <i>item</i>) <==> #T(<b>aref</b> (<i>index</i>) <i>item</i>)
</pre>
</p>
<h2>Examples:</h2>
<p>
<pre>
cl-prompt> (setf e (unify #(0 1 42 3 4 5) #T(<b>aref</b> 2 ?x)))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
42
cl-prompt> (setq e (unify #(0 1 42 3 4 5) #T(<b>aref</b> 42 ?x)))
--> Error: index 42 out of bounds.
cl-prompt> (setq e (unify 42 #T(<b>aref</b> 42 ?x)))
--> Error: UNIFICATION-FAILURE
cl-prompt> (setq e (unify "This is a string!" #T(<b>aref</b> 4 ?x)))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
#\Space
cl-prompt> (setq e (unify #2A((1 0) (foo bar)) #T(<b>aref</b> (1 1) ?x)))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
BAR
cl-prompt> (setq e (unify #2A((1 0) (foo bar)) #T(<b>aref</b> (1 1) baz)))
--> Error: UNIFICATION-FAILURE
cl-prompt> (setq e (unify #2A((1 0) (foo ?x)) #T(<b>aref</b> (1 1) baz)))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
BAZ
</pre>
</p>
<h2>Affected By:</h2>
<p>None.</p>
<h2>Exceptional Situations:</h2>
<p>Unifying an AREF-TEMPLATE against a non-ARRAY object results in
an UNIFICATION-FAILURE error being signaled.</p>
<h2>See Also:</h2>
<p>UNIFY</p>
<h2>Notes:</h2>
<p>None.</p>
</td>
<!-- <td height="100%">&nbsp;</td> -->
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<!--
<h1>News</h1>
<p>News in chronological order, most recent on top.
</p>
<ul>
<li><strong>2004-06-11</strong><br>
Completed description.
</li>
</ul>
-->
</div>
</div>
</td>
<td height="100%">&nbsp;</td>
</tr>
<tr>
<td colspan="3" valign="bottom" align="right">
<div class="copyright">
&copy; 2003-2013, Marco Antoniotti, all rights reserved.
</div>
</td>
</tr>
</table>
</body>
</html>
<!-- end of file -- expression-template-class.html -->
<html>
<head>
<title>CL Unification: Class ARRAY-TEMPLATE</title>
<link rel="stylesheet" href="../main.css">
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" bgcolor="#ffffff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" vspace="0" hspace="0">
<tr>
<td colspan="3">
<div class="header"
style="font-family:=Verdana,Arial,Helvetica; font-size: 18px; color: #41286f;">
<strong><i>CL Unification: Class ARRAY-TEMPLATE</title></i></strong>
<div class="navigation">
<a href="index.html" class="navigation-link">Home</a>
| <a href="../unification-dictionary.html" class="navigation-link">Dictionary</a>
| <a href="type-template-class.html" class="navigation-link">Previous</a>
| <a href="nil-template-class.html" class="navigation-link">Next</a>
| <a href="downloads.html" class="navigation-link">Downloads</a>
| <a href="links.html" class="navigation-link">Links</a>
</div>
</div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
<div class="middle-bar"><img src="images/shim.gif" height="5" width="1"></div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
</td>
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<h1><i>Class</i> <strong>ARRAY-TEMPLATE</strong></h1>
<h2>Package:</h2>
<p><code>COMMON-LISP.EXTENSIONS.DATA-AND-CONTROL-FLOW.UNIFICATION</code></p>
<h2>Class Precedence List:</h2>
<p>
ARRAY-TEMPLATE, TYPE-TEMPLATE, TEMPLATE, STANDARD-OBJECT, T.
</p>
<h2>Known Subclasses:</h2>
<p>
VECTOR-TEMPLATE.
</p>
<h2>Slots:</h2>
<p>None.</p>
<h2>Description:</h2>
<p>The ARRAY-TEMPLATE class denotes those object that are used
to unify against an ARRAY.</p>
<h3>Template Syntax:</h3>
<p>
<pre>
#T(<b>array</b> <i>&lt;shape-template&gt;</i>)
</pre>
</p>
<p>
<pre>
#T(<i>&lt;<strong>CL</strong> array type specifier&gt;</i> <i>&lt;shape-template&gt;</i>)
</pre>
</p>
<p>
<pre>
#T(<b>array</b> ([* | <i>&lt;<strong>CL</strong> type specifier&gt;</i>] [<i>&lt;dimension sped&gt;</i>]) <i>&lt;shape-template&gt;</i>)
</pre>
</p>
<p>Where <i>&lt;shape-template&gt;</i> can be:</p>
<p>
<pre>
<i>&lt;shape-template&gt;</i> ::= <i>&lt;sequence-template&gt;</i>
| <i>&lt;destructuring template lambda list&gt;</i>
| (<i>&lt;shape-template&gt;</i>)
</pre>
</p>
<p>The ARRAY-TEMPLATE syntax denotes an ARRAY object. An
ARRAY-TEMPLATE must be unified against an ARRAY object. The elements
of the array must be unified against the
<i>&lt;shape-template&gt;</i>. Each row of the array is unified
recursively against each element of the <i>&lt;shape-template&gt;</i>.
<h2>Examples:</h2>
<p>
<pre>
cl-prompt> (setf e (unify #(0 1 42 3 4 5) #T(<b>array</b> (0 1 ?x 3 4 5))))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
42
cl-prompt> (setq e (unify #(0 1 42 3 4 5) #T(<b>array</b> (0 1 "FOO" 3 4 5))))
--> Error: UNIFICATION-FAILURE
cl-prompt> (setq e (unify #2A((0 1 42) (3 4 5)) #T(<b>array</b> ((0 1 ?x) (3 4 5)))))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
42
cl-prompt> (setq e (unify #2A(("foo" "bar" 42) (3 4 5)) #T(<b>array</b> ((_ _ ?x) (3 4 5)))))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
42
cl-prompt> (setq e (unify #2A(("foo" "bar" 42) (3 4 5)) #T(<b>array</b> (#T(vector _ &rest ?x) (3 4 5)))))
#&lt;ENVIRONMENT xxx&gt;
cl-prompt> (find-variable-value '?x e)
#("bar" 42)
</pre>
</p>
<h2>Affected By:</h2>
<p>None.</p>
<h2>Exceptional Situations:</h2>
<p>Unifying an ARRAY-TEMPLATE against a non-ARRAY object results in
an UNIFICATION-FAILURE error being signaled.</p>
<h2>See Also:</h2>
<p>UNIFY</p>
<h2>Notes:</h2>
<h3>Syntax Note</h3>
<p>The ARRAY-TEMPLATE syntax tries to be easy to use, at the cost of
being overloaded. There is no actual need to have the separate
forms <code>(<b>array</b> (fixnum) ...)</code> and
<code>((<b>array</b> fixnum) ...)</code>.</p>
<p>In a future release they may be conflated. For the time being
they are kept separate as it is unclear which would be better to
provide.</p>
<h3>Elements Unification</h3>
<p>It would be nice to have the possibility to unify against
<em>slices</em> of the array. Alas, this seems non trivial to get
right, and it is left as a future extension of the semantics of
<i>&lt;shape-template&gt;</i>.</p>
<h3>ARRAY Structural Properties</h3>
<p>There is no way to "unify" against structural properties of
vectors like fill pointers and displacements.</p>
</td>
<!-- <td height="100%">&nbsp;</td> -->
</tr>
<tr height="100%">
<td height="100%">&nbsp;</td>
<td valign="top" width="80%" height="100%">
<div class="content">
<div class="text" style="padding-top: 10px;">
<!--
<h1>News</h1>
<p>News in chronological order, most recent on top.
</p>
<ul>
<li><strong>2004-10-30</strong><br>
Completed description.
</li>
</ul>
-->
</div>
</div>
</td>
<td height="100%">&nbsp;</td>
</tr>
<tr>
<td colspan="3" valign="bottom" align="right">
<div class="copyright">
&copy; 2003-2013, Marco Antoniotti, all rights reserved.
</div>
</td>
</tr>
</table>
</body>
</html>
<!-- end of file -- expression-template-class.html -->
<html>
<head>
<title>CL Unification: Class ELEMENT-TEMPLATE</title>
<link rel="stylesheet" href="../main.css">
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" bgcolor="#ffffff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" vspace="0" hspace="0">
<tr>
<td colspan="3">
<div class="header"
style="font-family:=Verdana,Arial,Helvetica; font-size: 18px; color: #41286f;">
<strong><i>CL Unification: Class ELEMENT-TEMPLATE</title></i></strong>
<div class="navigation">
<a href="index.html" class="navigation-link">Home</a>
| <a href="../unification-dictionary.html" class="navigation-link">Dictionary</a>
| <a href="expression-template-class.html" class="navigation-link">Previous</a>
| <a href="aref-template-class.html" class="navigation-link">Next</a>
| <a href="downloads.html" class="navigation-link">Downloads</a>
| <a href="links.html" class="navigation-link">Links</a>
</div>
</div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>
<div class="middle-bar"><img src="images/shim.gif" height="5" width="1"></div>
<div class="black-line"><img src="images/shim.gif" height="1" width="1"></div>