File: return_002dfrom.html

package info (click to toggle)
gcl 2.6.14-21
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 60,864 kB
  • sloc: ansic: 177,407; lisp: 151,509; asm: 128,169; sh: 22,510; cpp: 11,923; tcl: 3,181; perl: 2,930; makefile: 2,360; sed: 334; yacc: 226; lex: 95; awk: 30; fortran: 24; csh: 23
file content (141 lines) | stat: -rw-r--r-- 5,057 bytes parent folder | download | duplicates (4)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!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-from (ANSI and GNU Common Lisp Document)</title>

<meta name="description" content="return-from (ANSI and GNU Common Lisp Document)">
<meta name="keywords" content="return-from (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="return.html" rel="next" title="return">
<link href="go.html" rel="prev" title="go">
<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_002dfrom"></span><div class="header">
<p>
Next: <a href="return.html" accesskey="n" rel="next">return</a>, Previous: <a href="go.html" accesskey="p" rel="prev">go</a>, Up: <a href="Data-and-Control-Flow-Dictionary.html" accesskey="u" rel="up">Data and Control Flow Dictionary</a> &nbsp; </p>
</div>
<hr>
<span id="return_002dfrom-_005bSpecial-Operator_005d"></span><h4 class="subsection">5.3.25 return-from                                              [Special Operator]</h4>

<p><code>return-from</code>  <i><i>name</i> <span class="roman">[</span><i>result</i><span class="roman">]</span></i> 
        &rArr;  #&lt;NoValue&gt;
</p><span id="Arguments-and-Values_003a_003a-46"></span><h4 class="subsubheading">Arguments and Values::</h4>

<p><i>name</i>&mdash;a <i>block tag</i>; not evaluated.
</p>
<p><i>result</i>&mdash;a <i>form</i>; evaluated.
  The default is <b>nil</b>.
</p>
<span id="Description_003a_003a-78"></span><h4 class="subsubheading">Description::</h4>

<p>Returns control and <i>multiple values</i>_2 from a lexically enclosing <i>block</i>.
</p>
<p>A <b>block</b> <i>form</i> named <i>name</i> must lexically enclose
the occurrence of <b>return-from</b>;  any <i>values</i> <i>yielded</i>
by the <i>evaluation</i> of <i>result</i> are immediately returned from
the innermost such lexically enclosing <i>block</i>.
</p>
<p>The transfer of control initiated by <b>return-from</b> is performed
as described in <a href="Transfer-of-Control-to-an-Exit-Point.html">Transfer of Control to an Exit Point</a>.
</p>
<span id="Examples_003a_003a-52"></span><h4 class="subsubheading">Examples::</h4>

<div class="example">
<pre class="example"> (block alpha (return-from alpha) 1) &rArr;  NIL
 (block alpha (return-from alpha 1) 2) &rArr;  1
 (block alpha (return-from alpha (values 1 2)) 3) &rArr;  1, 2
 (let ((a 0))
    (dotimes (i 10) (incf a) (when (oddp i) (return)))
    a) &rArr;  2
 (defun temp (x)
    (if x (return-from temp 'dummy))
    44) &rArr;  TEMP
 (temp nil) &rArr;  44
 (temp t) &rArr;  DUMMY
 (block out
   (flet ((exit (n) (return-from out n)))
     (block out (exit 1)))
   2) &rArr;  1
 (block nil   
   (unwind-protect (return-from nil 1)
     (return-from nil 2)))
&rArr;  2
 (dolist (flag '(nil t))
   (block nil
     (let ((x 5))
       (declare (special x))
       (unwind-protect (return-from nil)
         (print x))))
   (print 'here))
<tt> |&gt; </tt> 5
<tt> |&gt; </tt> HERE
<tt> |&gt; </tt> 5
<tt> |&gt; </tt> HERE
&rArr;  NIL
 (dolist (flag '(nil t))
   (block nil
     (let ((x 5))
       (declare (special x))
       (unwind-protect
           (if flag (return-from nil))
         (print x))))
   (print 'here))
<tt> |&gt; </tt> 5
<tt> |&gt; </tt> HERE
<tt> |&gt; </tt> 5
<tt> |&gt; </tt> HERE
&rArr;  NIL
</pre></div>

<p>The following has undefined consequences because the <b>block</b> <i>form</i>
exits normally before the <b>return-from</b> <i>form</i> is attempted.
</p>
<div class="example">
<pre class="example"> (funcall (block nil #'(lambda () (return-from nil)))) is an error.
</pre></div>

<span id="See-Also_003a_003a-63"></span><h4 class="subsubheading">See Also::</h4>

<p><a href="block.html">block</a>
,
<a href="return.html">return</a>
,
<a href="Evaluation.html">Evaluation</a>
</p>
<hr>
<div class="header">
<p>
Next: <a href="return.html" accesskey="n" rel="next">return</a>, Previous: <a href="go.html" accesskey="p" rel="prev">go</a>, Up: <a href="Data-and-Control-Flow-Dictionary.html" accesskey="u" rel="up">Data and Control Flow Dictionary</a> &nbsp; </p>
</div>



</body>
</html>