User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:macros:destructuring-bind [2019/12/05 03:00]
cl:macros:destructuring-bind [2019/12/15 16:00] (current)
Line 1: Line 1:
 +====== Macro DESTRUCTURING-BIND ======
 +
 +====Syntax====
 +  *  **destructuring-bind** //​lambda-list expression declaration''​*''​ form''​*''//​ //​result''​*''//​
 +
 +====Arguments and Values====
 +  * //​lambda-list//​ - a //​[[CL:​Glossary:​destructuring lambda list]]//.
 +  * //​expression//​ - a //​[[CL:​Glossary:​form]]//​.
 +  * //​declaration//​ - a **[[CL:​Special Operators:​declare]]** //​[[CL:​Glossary:​expression]]//;​ not evaluated.
 +  * //form//s - an //​[[CL:​Glossary:​implicit progn]]//.
 +  * //result//s - the //​[[CL:​Glossary:​value|values]]//​ returned by the //​[[CL:​Glossary:​form|forms]]//​.
 +
 +====Description====
 +**destructuring-bind** binds the variables specified in //​lambda-list//​ to the corresponding values in the tree structure resulting from the evaluation of //​expression//;​ then **destructuring-bind** evaluates //form//s.
 +
 +The //​lambda-list//​ supports destructuring as described in \secref\DestructuringLambdaLists.
 +
 +====Examples====
 +<​blockquote>​
 +;;; TODO better examples for this, d-bind really deserves more love
 +
 +(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)) <​r>​(ALPHA BEE 3 2 1)</​r>​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +If the result of evaluating the //​expression//​ does not match the destructuring pattern, an error of type **[[CL:​Types:​error]]** should be signaled.
 +
 +====See Also====
 +  * **[[CL:​Special Operators:​macrolet|Special Operator MACROLET]]**
 +  * **[[CL:​Macros:​defmacro|Macro DEFMACRO]]**
 +
 +====Notes====
 +None.
 +
 +\issue{DECLS-AND-DOC} \issue{DESTRUCTURING-BIND:​NEW-MACRO}