1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>destructuring-bind (ANSI and GNU Common Lisp Document)</title>
<meta name="description" content="destructuring-bind (ANSI and GNU Common Lisp Document)">
<meta name="keywords" content="destructuring-bind (ANSI and GNU Common Lisp Document)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Data-and-Control-Flow-Dictionary.html" rel="up" title="Data and Control Flow Dictionary">
<link href="let.html" rel="next" title="let">
<link href="defparameter.html" rel="prev" title="defparameter">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<span id="destructuring_002dbind"></span><div class="header">
<p>
Next: <a href="let.html" accesskey="n" rel="next">let</a>, Previous: <a href="defparameter.html" accesskey="p" rel="prev">defparameter</a>, Up: <a href="Data-and-Control-Flow-Dictionary.html" accesskey="u" rel="up">Data and Control Flow Dictionary</a> </p>
</div>
<hr>
<span id="destructuring_002dbind-_005bMacro_005d"></span><h4 class="subsection">5.3.17 destructuring-bind [Macro]</h4>
<p><code>destructuring-bind</code> <i>lambda-list expression {<i>declaration</i>}* {<i>form</i>}*</i><br>
⇒ <i>{<i>result</i>}*</i>
</p>
<span id="Arguments-and-Values_003a_003a-38"></span><h4 class="subsubheading">Arguments and Values::</h4>
<p><i>lambda-list</i>—a <i>destructuring lambda list</i>.
</p>
<p><i>expression</i>—a <i>form</i>.
</p>
<p><i>declaration</i>—a <b>declare</b> <i>expression</i>; not evaluated.
</p>
<p><i>forms</i>—an <i>implicit progn</i>.
</p>
<p><i>results</i>—the <i>values</i> returned by the <i>forms</i>.
</p>
<span id="Description_003a_003a-70"></span><h4 class="subsubheading">Description::</h4>
<p><b>destructuring-bind</b> binds the variables specified in <i>lambda-list</i>
to the corresponding values in the tree structure resulting from the evaluation
of <i>expression</i>; then <b>destructuring-bind</b> evaluates <i>forms</i>.
</p>
<p>The <i>lambda-list</i> supports destructuring as described in
<a href="Destructuring-Lambda-Lists.html">Destructuring Lambda Lists</a>.
</p>
<span id="Examples_003a_003a-44"></span><h4 class="subsubheading">Examples::</h4>
<div class="example">
<pre class="example"> (defun iota (n) (loop for i from 1 to n collect i)) ;helper
(destructuring-bind ((a &optional (b 'bee)) one two three)
`((alpha) ,@(iota 3))
(list a b three two one)) ⇒ (ALPHA BEE 3 2 1)
</pre></div>
<span id="Exceptional-Situations_003a_003a-14"></span><h4 class="subsubheading">Exceptional Situations::</h4>
<p>If the result of evaluating the <i>expression</i> does not match the
destructuring pattern, an error of <i>type</i> <b>error</b> should be signaled.
</p>
<span id="See-Also_003a_003a-55"></span><h4 class="subsubheading">See Also::</h4>
<p><b>macrolet</b>,
<a href="defmacro.html">defmacro</a>
</p>
</body>
</html>
|