This shows you the differences between two versions of the page.
cl:macros:multiple-value-bind [2019/08/16 12:00] |
cl:macros:multiple-value-bind [2019/12/10 04:00] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Macro MULTIPLE-VALUE-BIND ====== | ||
+ | |||
+ | ====Syntax==== | ||
+ | * multiple-value-bind //(var''*'') values-form declaration''*'' form''*''// → //result''*''// | ||
+ | |||
+ | ====Arguments and Values==== | ||
+ | * //var// - a //[[CL:Glossary:symbol]]// naming a variable; not evaluated. | ||
+ | * //values-form// - a //[[CL:Glossary:form]]//; evaluated. | ||
+ | * //declaration// - a **[[CL:Special Operators:declare]]** //[[CL:Glossary:expression]]//; not evaluated. | ||
+ | * //forms// - an //[[CL:Glossary:implicit progn]]//. | ||
+ | * //results// - the //[[CL:Glossary:value|values]]// returned by the //forms//. | ||
+ | |||
+ | ====Description==== | ||
+ | Creates new variable //[[CL:Glossary:binding|bindings]]// for the //vars// and executes a series of //forms// that use these //[[CL:Glossary:binding|bindings]]//. | ||
+ | |||
+ | The variable //[[CL:Glossary:binding|bindings]]// created are lexical unless **[[CL:Declarations:special]]** declarations are specified. | ||
+ | |||
+ | //Values-form// is evaluated, and each of the //vars// is bound to the respective value returned by that //[[CL:Glossary:form]]//. If there are more //vars// than values returned, extra values of **[[CL:Constant Variables:nil]]** are given to the remaining //vars//. If there are more values than //vars//, the excess values are discarded. The //vars// are bound to the values over the execution of the //forms//, which make up an implicit **[[CL:Special Operators:progn]]**. The consequences are unspecified if a type //declaration// is specified for a //var//, but the value to which that //var// is bound is not consistent with the type //declaration//. | ||
+ | |||
+ | The //[[CL:Glossary:scopes]]// of the name binding and //declarations// do not include the //values-form//. | ||
+ | |||
+ | ====Examples==== | ||
+ | <blockquote> | ||
+ | (multiple-value-bind (f r) | ||
+ | ([[CL:Functions:floor]] 130 11) | ||
+ | ([[CL:Functions:list]] f r)) <r>(11 9)</r> | ||
+ | </blockquote> | ||
+ | |||
+ | ====Affected By==== | ||
+ | None. | ||
+ | |||
+ | ====Exceptional Situations==== | ||
+ | None. | ||
+ | |||
+ | ====See Also==== | ||
+ | * **[[CL:Special Operators:let|Special Operator LET]]** | ||
+ | * **[[CL:Special Operators:multiple-value-call|Special Operator MULTIPLE-VALUE-CALL]]** | ||
+ | |||
+ | ====Notes==== | ||
+ | <blockquote> | ||
+ | (multiple-value-bind (//var''*''//) //values-form// //form''*''//) | ||
+ | ≡ ([[CL:Special Operators:multiple-value-call]] #'([[CL:Symbols:lambda]] (&optional //var''*''// &rest #1=#:ignore) | ||
+ | ([[CL:Symbols:declare]] ([[CL:Declarations:ignore]] #1#)) | ||
+ | //form''*''//) | ||
+ | //values-form//) | ||
+ | </blockquote> | ||
+ | |||
+ | \issue{DECLS-AND-DOC} | ||