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: <1320@uw-entropy.ms.washington.edu> Date: 16 Mar 89 20:40:16 GMT References: <458@orange19.qtp.ufl.edu> <28506@sgi.SGI.COM> <1317@uw-entropy.ms.washington.edu> <1905@devsys.oakhill.UUCP> Sender: news@uw-entropy.ms.washington.edu Reply-To: charlie@mica.stat.washington.edu (Charlie Geyer) Organization: UW Statistics, Seattle Lines: 60 Summary: Expires: Sender: Followup-To: In article <1317@uw-entropy.ms.washington.edu>, I wrote: 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. In article <1905@devsys.oakhill.UUCP> steve@oakhill.UUCP (steve) replies: > As I stated in my previous post. There is NO problem with the code as > posted. It is not ambiguous. The problem is that the compiler, in > order to prevent any posssible ambiguity, generates bad code. The > true ambiguity results in the following three elements used together. > > 1) Two or more do loops ending on the same line. > 2) One or more of the external do loops (not the inner most) > jumping to the terminating statement. > 3) The terminating statement being executable (not a CONTINUE). The code as posted (we are still talking about the original posting aren't we?) is, as several other people have pointed out, wrong. It DOES have a problem. It jumps into the range of an inactive DO loop. This is forbidden. It is not the job of a compiler to guess what conforming program the programmer thought he was writing. It would be nice for compilers to produce code that catches this error, at least as an option. > Admittedly the practice of ending do loops on the same line is not > sound programming. But it is historic programming, and is still used > today. As for the performance hit you talk about, well that's part of > the problem here. So make it an option that can be turned off. In article <18178@vax5.CIT.CORNELL.EDU> btcx@vax5.cit.cornell.edu (Brian T Carcich) replies: > Well, not quite. > > Now, I'm not a GOTO freak, and I learned to only goto CONTINUE's, but > does anybody realize the origin of the anti-GOTO religion? And how the above > statement is a misrepresentation of that origin? (see BTW below) > > It's not GOTO's that are harmful, but POOR USE OF goto's that's harmful. O. K., but that would have made a much weaker punchline. If you want to be pedantic, unstructured use of GOTO's is harmful, and jumping in and out of DO loops is about as unstructured as you can get. Is that o.k.? > Go back to .c or .pascal or .modula or ... where you belong. > leave us dinosaurs alone! Believe me. I don't write FORTRAN by choice. Lately I've taken to writing some of my FORTRAN in C (thereby incurring who knows what portability problems). But you just can't ever get completely away from FORTRAN. It's everywhere.