Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!uw-entropy!mica!charlie From: charlie@mica.stat.washington.edu (Charlie Geyer) Newsgroups: comp.lang.fortran Subject: Re: DO loops, anyone? Message-ID: <1317@uw-entropy.ms.washington.edu> Date: 16 Mar 89 02:20:09 GMT References: <458@orange19.qtp.ufl.edu> <28506@sgi.SGI.COM> <22754@ames.arc.nasa.gov> <6667@ecsvax.UUCP> Sender: news@uw-entropy.ms.washington.edu Reply-To: charlie@mica.stat.washington.edu (Charlie Geyer) Organization: UW Statistics, Seattle Lines: 23 Summary: Expires: Sender: Followup-To: In article <6667@ecsvax.UUCP> urjlew@ecsvax.UUCP (Rostyk Lewyckyj) writes: > The problem is that the standard allows a code construction that > easily leads to misuse and stepping over the legal limits. I.e. > the standard permits a DO loop to end with non trivial executable > statements (eg k=k+1 rather than continue or enddo) and it allows > the closure of multiple DO loops on one statement. > The defensive/safety minded programmer can easily avoid the problem > by liberal use of CONTINUE statements to remove ambiguities. > I think that the rational solution is to amend the standard (put it > in 8x or 9x if 8x never makes it) to require DO loops to be terminated > one at a time with CONTINUE or ENDDO statements. > I realize that this will require modifying old source. A simpler solution would have compilers do run-time error checking and not jump into inactive loops. The beauty of this solution is that it does not not slow down structured code -- no checking necessary. Unstructured code would take a performance hit. Serves it right :-) It's not failure to end every loop with its own CONTINUE that is the problem. It is (surprise!) GOTO's are harmful.