"Stephen Leake" a �crit dans le message news: u3cqg9b8l.fsf@gsfc.nasa.gov... > Fraser Wilson writes: > > > ... Isn't there a preference hierarchy from for loop to while > > loop to loop? I.e. use a for loop whenever possible, failing that a > > while loop, and as a last resort a loop with an exit. OK, and as a > > last last resort use a goto. > > In my style guide, I use a for loop _only_ if the loop will _always_ > be executed exactly as indicated in the "for" part. No other loop > exits allowed. > I beg to differ. A for loop preserves you from a number of problem, especially when dealing with limit cases. Try to write a loop that does *exactly* what for does, and you'll see that there are lots of benefits in using for. For example, I always use a for in a search loop, which exits when the element is found. In Pascal, a for loop was always done entirely; you have to be aware that Ada is different in that respect, but that does not mean that you should not use a more powerful construct when you can. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr