Re: how do people feel about exit function from loop




"Michael C" <nospam@xxxxxxxxxx> wrote in message
news:OLiqFbm0HHA.1164@xxxxxxxxxxxxxxxxxxxxxxx
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eM%239lSm0HHA.5380@xxxxxxxxxxxxxxxxxxxxxxx
You know, I think you've gotten to the heart of why I don't like Exit For and
similar constructs, never mind that structured programming says you shouldn't
use them. Imagine a complex loop rendered into English:

For w. Exits
"For each of these items, I want you to do some things to them. Except if
you run across this. Oh, and also stop if you find something else. Or if
you run into any problems."

While/Until/etc.
"Unless you run across this, find something else, or run into any
problems, do some things to each of these items."

Actually the first seems MUCH more logical to me. Open all these boxes, stop
when you find the money. Just like the programming example it's much simpler
:-)

Michael


I think Robert has stumbled onto something here. Neither of the two sounds
particularly good when rendered into spoken English. It highlights the fact that
the loop in quesiton is inherently messy. The For w Exits starts off boldly,
then tacks on a list of lame excuses, sounding like a typical politician. The
second lists so many conditions first, you wonder if you will ever get to the
heart of the matter, making you think you are up against a career bureaucrat.

Neither the For loop nor the While loop exactly match the problem - what you
need is a new loop structure. Of course, then Michael would insist it be called
the For While loop, and Robert would demand it be called the While For loop, and
we would have to endure another long ping pong match - so nevermind. :)



.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... >> Why not code it like you would read it in English: ... > glance that the loop is an infinite one; ... > represents a condition that will become true when the loop is meant to ... That program WILL terminate sometime. ...
    (comp.lang.c)
  • Re: Number of rows in xls file
    ... No problem with English. ... I think I can figure out how to stop the loop from the ... Gerry Metze ... >> data on you sheet? ...
    (microsoft.public.excel.misc)
  • Re: Plzz Explain !!
    ... The loop terminates when the middle bit evaluates to zero. ... stupid things like putting printfs in the condition. ... This is inherent inthe English language meaning of the words. ... That is not how I would talk in English about processing a file or a linked lists or many other things. ...
    (comp.lang.c)
  • Re: while (1) vs. for ( ;; )
    ... Because clear English is not necessarily clear C. ... represents a condition that will become true when the loop is meant to ... I assume that anyone reading my code either is familiar with C, ...
    (comp.lang.c)
  • Re: Programming: Not stressful? Yeah, right...
    ... > minimize the use of branch or jump instructions. ... > use a forward jump to produce a loop only makes things worse. ... structured programming would be for hardware with no branch or jump. ...
    (comp.programming)