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
|
<!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>Return Values (ANSI and GNU Common Lisp Document)</title>
<meta name="description" content="Return Values (ANSI and GNU Common Lisp Document)">
<meta name="keywords" content="Return Values (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="Evaluation.html" rel="up" title="Evaluation">
<link href="Compilation.html" rel="next" title="Compilation">
<link href="Extent.html" rel="prev" title="Extent">
<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="Return-Values"></span><div class="header">
<p>
Previous: <a href="Extent.html" accesskey="p" rel="prev">Extent</a>, Up: <a href="Evaluation.html" accesskey="u" rel="up">Evaluation</a> </p>
</div>
<hr>
<span id="Return-Values-1"></span><h4 class="subsection">3.1.7 Return Values</h4>
<p>Ordinarily the result of calling a <i>function</i> is a single <i>object</i>.
Sometimes, however, it is convenient for a function to compute several
<i>objects</i> and return them.
</p>
<p>In order to receive other than exactly one value from a <i>form</i>,
one of several <i>special forms</i> or <i>macros</i> must be used to request those
values. If a <i>form</i> produces <i>multiple values</i> which were not
requested in this way, then the first value is given to the caller and
all others are discarded; if the <i>form</i> produces zero values,
then the caller receives <b>nil</b> as a value.
</p>
<p>Figure 3–5 lists
some <i>operators</i> for receiving <i>multiple values</i>_2.
These <i>operators</i> can be used to specify
one or more <i>forms</i> to <i>evaluate</i>
and where to put the <i>values</i> returned by those <i>forms</i>.
</p>
<div class="format">
<pre class="format"> multiple-value-bind multiple-value-prog1 return-from <!-- /@w -->
multiple-value-call multiple-value-setq throw <!-- /@w -->
multiple-value-list return <!-- /@w -->
Figure 3–5: Some operators applicable to receiving multiple values<!-- /@w -->
</pre></div>
<p>The <i>function</i> <b>values</b> can produce <i>multiple values</i>_2.
<tt>(values)</tt> returns zero values;
<tt>(values <i>form</i>)</tt> returns the <i>primary value</i> returned by <i>form</i>;
<tt>(values <i>form1</i> <i>form2</i>)</tt> returns two values,
the <i>primary value</i> of <i>form1</i>
and the <i>primary value</i> of <i>form2</i>;
and so on.
</p>
<p>See <b>multiple-values-limit</b> and <b>values-list</b>.
</p>
</body>
</html>
|