I haven't read the whole thing but I like this bit:
> There are many algorithms that are best written using an exit from the middle of a loop. If not written in this fashion, techniques such as the traditional “priming” of a loop must be used. For example, in reading a file:
read(a, b, c)
WHILE NOT eof DO
{ process a, b, & c }
read(a, b, c)
END WHILE
LOOP
read(a, b, c)
WHEN eof EXIT
{ process a, b, & c }
END LOOP
> The example on the left [top] shows the priming of a loop. This requires duplication of the READ statement or, in other cases, creation of a subprogram to eliminate the duplication, both of which are undesirable. As well, loop priming can be done an arbitrary distance before the beginning of the loop making the program difficult to read as the priming statement(s) is critical to the understanding of the loop.
Re:Let’s Build a Web Server. Part 1
by _asummers on Friday April 03, 2015 @09:02PM
(#9319458)
This wasn't really my question. I was asking about the different infinite loop idioms in C family languages and the rationale for using one over the other.
I haven't read the whole thing but I like this bit:
> There are many algorithms that are best written using an exit from the middle of a loop. If not written in this fashion, techniques such as the traditional “priming” of a loop must be used. For example, in reading a file:
> The example on the left [top] shows the priming of a loop. This requires duplication of the READ statement or, in other cases, creation of a subprogram to eliminate the duplication, both of which are undesirable. As well, loop priming can be done an arbitrary distance before the beginning of the loop making the program difficult to read as the priming statement(s) is critical to the understanding of the loop.