OEP

139

Title

Expanded WHILE

Summary

Allow multiple exit points from a WHILE loop.

Owner

Adam Sampson <ats@offog.org>

Status

Proposed

Date-Proposed

2006-03-14

Keywords

language while honeysuckle

The Honeysuckle language features a very general loop construct which allows multiple exit points in a way that preserves a clear structure for the loop. It would be possible to extend occam-pi's WHILE loops so that they could perform several tests per iteration; this could remove the need for running variables from some types of loops (and would make WHILE a neater inverse of IF in some ways):

WHILE
  guard.1
    process.1
  guard.2
    process.2
  guard.3
    process.3

The semantics would be that the loop would continue to execute while all of its guards remained TRUE; as soon as the loop encounters a guard which has become FALSE, it exits. Specifying a constant TRUE guard would allow an action to be performed before the first test (for example, reading data from a file, with the next test being for a terminator value) -- a common idiom that many languages do not handle well. (Specifying a constant FALSE guard would allow a block of code with multiple exit points that did not repeat; the utility of this is obvious, but the clarity is dubious.)

OEP/139 (last edited 2007-09-27 01:04:20 by ats1)