/[guile]/guile/guile-core/doc/ref/scheme-control.texi
ViewVC logotype

Diff of /guile/guile-core/doc/ref/scheme-control.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by kryde, Thu Jul 24 00:30:31 2003 UTC revision 1.12 by kryde, Tue Aug 12 21:48:27 2003 UTC
# Line 197  corresponding variable is not changed du Line 197  corresponding variable is not changed du
197  @end deffn  @end deffn
198    
199  @deffn syntax while cond body @dots{}  @deffn syntax while cond body @dots{}
200  Evaluate all expressions in @var{body} in order, as long as @var{cond}  Run a loop executing the @var{body} forms while @var{cond} is true.
201  evaluates to a true value.  The @var{cond} expression is tested before  @var{cond} is tested at the start of each iteration, so if it's
202  every iteration, so that the body is not evaluated at all if @var{cond}  @code{#f} the first time then @var{body} is not executed at all.  The
203  is @code{#f} right from the start.  return value is unspecified.
204    
205    Within @code{while}, two extra bindings are provided, they can be used
206    from both @var{cond} and @var{body}.
207    
208    @deffn {Scheme Procedure} break
209    Break out of the @code{while} form.
210    @end deffn
211    
212    @deffn {Scheme Procedure} continue
213    Abandon the current iteration, go back to the start and test
214    @var{cond} again, etc.
215    @end deffn
216    
217    Each @code{while} form gets its own @code{break} and @code{continue}
218    procedures, operating on that @code{while}.  This means when loops are
219    nested the outer @code{break} can be used to escape all the way out.
220    For example,
221    
222    @example
223    (while (test1)
224      (let ((outer-break break))
225        (while (test2)
226          (if (something)
227            (outer-break #f))
228          ...)))
229    @end example
230    
231    Note that each @code{break} and @code{continue} procedure can only be
232    used within the dynamic extent of its @code{while}.  Outside the
233    @code{while} their behaviour is unspecified.
234  @end deffn  @end deffn
235    
236  @cindex named let  @cindex named let

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26