guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: while break and continue


From: Kevin Ryde
Subject: Re: while break and continue
Date: Thu, 14 Aug 2003 07:49:30 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

I applied this

        * boot-9.scm (while): Rewrite, continue as a proper escape, break
        doesn't take a return value, break and continue procs new for each
        while form allowing use in nested whiles, don't depend on bindings in
        expansion environment.

        * tests/syntax.test (while): New tests.

        * scheme-control.texi (while do): Update `while' for code rewrite, in
        particular describe break and continue.


 - syntax: while cond body ...
     Run a loop executing the BODY forms while COND is true.  COND is
     tested at the start of each iteration, so if it's `#f' the first
     time then BODY is not executed at all.  The return value is
     unspecified.

     Within `while', two extra bindings are provided, they can be used
     from both COND and BODY.

      - Scheme Procedure: break
          Break out of the `while' form.

      - Scheme Procedure: continue
          Abandon the current iteration, go back to the start and test
          COND again, etc.

     Each `while' form gets its own `break' and `continue' procedures,
     operating on that `while'.  This means when loops are nested the
     outer `break' can be used to escape all the way out.  For example,

          (while (test1)
            (let ((outer-break break))
              (while (test2)
                (if (something)
                  (outer-break #f))
                ...)))

     Note that each `break' and `continue' procedure can only be used
     within the dynamic extent of its `while'.  Outside the `while'
     their behaviour is unspecified.



Attachment: boot-9.scm.while.diff
Description: Text document

Attachment: syntax.test.while.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]