Re: coding style: do/exit or do while ?



dpb wrote:

(snip regarding DO and WHILE loops)

And, of course, where amax and bmax are both external to the loop and
don't change (as I know they were postulated as constants here). But
oftentimes one will see the construction tried to be used where it
doesn't fit when one of the conditions is changing based on loop
execution and the test then is misplaced in the logic flow. Avoiding
this, I presume, is the prime reason for the proscription although I'm
fond of the "never say 'never' " dictum.

For those converting C to Fortran, the test in a C for loop is done
using the current values, and they can change. One should be careful:

for(i=1;i<=n;i++)

n can legally change inside the loop, and so might not translate to a
Fortran DO loop.

-- glen



.



Relevant Pages

  • Re: Various DOM-related wrappers (Code Worth Recommending Project)
    ... var start = ).getTime; ... sugar on top of what the browser offers. ... this was in a loop and I thought the join would be faster. ...
    (comp.lang.javascript)
  • Re: newbie: need inspiration
    ... Value holding input isn't really ... Loop should end when user ... That would be overloading the variable (it now has 2 purposes - ...
    (comp.unix.shell)
  • Re: Endless loop question
    ... > actually turn this while loop into an endless loop instead of waiting ... This reads a character but doesn't do anything with it, ... into a buffer with fgets, and then pick the desired data value ...
    (comp.lang.c)
  • Re: foreach vs for
    ... > c-style loop and the foreach loop was an iterator. ... Note, this is not real Huffman encoding, just Larry Wall's version of it. ...
    (perl.beginners)
  • Re: Behavior when a do-iterator is changed
    ... "The INTENT attribute for a nonpointer dummy argument ... Since a DO loop variable is not definable, ... with a nonconforming code, including start WW III." ... (snip is identical to 1first attempt because the module is never ...
    (comp.lang.fortran)