51 lines
2.7 KiB
HTML
51 lines
2.7 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>8.3. Destructuring</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Destructuring">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html2770 HREF="node101.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2768 HREF="node97.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2762 HREF="node99.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2772 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2773 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html2771 HREF="node101.html"> Compiler Macros</A>
|
||
|
<B>Up:</B> <A NAME=tex2html2769 HREF="node97.html"> Macros</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html2763 HREF="node99.html"> Macro Expansion</A>
|
||
|
<HR> <P>
|
||
|
<H1><A NAME=SECTION001230000000000000000>8.3. Destructuring</A></H1>
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
X3J13 voted in March 1989 (DESTRUCTURING-BIND) <A NAME=8600> </A>
|
||
|
to make the destructuring feature of <tt>defmacro</tt>
|
||
|
available as a separate facility.
|
||
|
<P>
|
||
|
<BR><b>[Macro]</b><BR>
|
||
|
<pre>
|
||
|
destructuring-bind <i>lambda-list</i> <i>expression</i> {<i>declaration</i>}* {<i>form</i>}*
|
||
|
</pre>
|
||
|
<P> This macro binds the variables specified in <i>lambda-list</i> to the corresponding
|
||
|
values in the tree structure resulting from evaluating the <i>expression</i>,
|
||
|
then executes the <i>form</i>s as an implicit <tt>progn</tt>.
|
||
|
<P>
|
||
|
A <tt>destructuring-bind</tt> <i>lambda-list</i> may contain
|
||
|
the lambda-list keywords <tt>&optional</tt>, <tt>&rest</tt>, <tt>&key</tt>,
|
||
|
<tt>&allow-other-keys</tt>, and <tt>&aux</tt>; <tt>&body</tt> and <tt>&whole</tt>
|
||
|
may also be used as they are in <tt>defmacro</tt>, but <tt>&environment</tt> may
|
||
|
<i>not</i> be used. Nested and dotted lambda-lists are also permitted
|
||
|
as for <tt>defmacro</tt>.
|
||
|
The idea is that a <tt>destructuring-bind</tt> <i>lambda-list</i>
|
||
|
has the same format as inner levels of a <tt>defmacro</tt> lambda-list.
|
||
|
<P>
|
||
|
If the result of evaluating the <i>expression</i> does not match the
|
||
|
destructuring pattern, an error should be signaled.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|