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

Re: simple question

Pavel Romashkin wrote:
> Isn't breaking out of DO loops the same as using conditional loops? FOR
> / DO have a particular purpose, to execute a  certain number of times.
> For repeating under a condition, WHILE and REPEAT are provided, I think.

I agree. But both WHILE and REPEAT exit the conditional loop once a
specified condition occurs. Sometimes, you don't want to exit the loop,
just skip the current cycle and continue. The existence of WHILE and
REPEAT certainly limit the need for a BREAK type of statement, but not a
CONTINUE (or CYCLE). In addition, the WHILE and REPEAT don't provide you
with the current loop index (i.e. you have to do your own i = i + 1
within the loop). I guess one's preference for using WHILE/REPEATs or
FOR loops with CONTINUE/BREAKs stems non-trivially from personal

Paul van Delst           Ph:  (301) 763-8000 x7274 
CIMSS @ NOAA/NCEP        Fax: (301) 763-8545
Rm.202, 5200 Auth Rd.    Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746