Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!arisia!sgi!calvin@dinkum.SGI.COM From: calvin@dinkum.SGI.COM (Calvin H. Vu) Newsgroups: comp.lang.fortran Subject: Re: DO loops, anyone? Summary: I was wrong. It is illegal. Message-ID: <28748@sgi.SGI.COM> Date: 15 Mar 89 21:22:18 GMT References: <458@orange19.qtp.ufl.edu> <28506@sgi.SGI.COM> <22754@ames.arc.nasa.gov> Sender: daemon@sgi.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 69 I guess I have been so inculcated with the ideas of block-structured programming where each block has a uniquely-identifiable nested level associated with it so I could not think straight in the way ANSI does in its amorphous definition of DO-loop range. I thought since the terminal statement was shared by the two ranges it must belong to both nested levels as an exception to the general rule! But, alah, there is no such thing as a nested level in ANSI. They just have a dozen different rules concerning cross-range activities & definitions to make sure that they don't mess anything up with their rules. In other words, a range in ANSI standard doesn't mean anything. It is simply a point-A-to-point-B definition and is in no way equivalent to the idea of a block which has an implied nested level associated with it. ANSI has to enforce dozens other rules to simulate the illusion of a block which caught me (and, apparently, some other people) off guard. In short, there is no such thing as a block in ANSI. If you want to make sure whether it is legal to do something according to ANSI standard or not, look it up the their numerous rules. I'm sure it is in there somewhere. BTW, I realized this after I had time to really peruse the ANSI standard and realize the full implication of all their rules after my Sunday posting/dinner. I would say that your argument is pretty good though, although it falls into the ANSI track of cerebration that you have to look up in the book and follows the rules instead of relying on your general concept of programming practice. > < to make this bitchy code portable and produce the correct result across > < most computers that do not declaring this as illegal, just add one > < > 5) as the terminating condition so I can't guarantee > > Yukk! In the name of "portability" you try to second guess the inner workings > of the compiler? Remind me not to try porting any of your code. To make > this code portable, add a continue statement with a separate statement > number as the terminator of the outer DO-loop. This is not only portable > (really - like it'll run on anything), it is even standard. What an odd > coincidence. I was so sure that the original poster knew about your approach that was why he asked not to be flamed for it. And now I got flamed because I wanted to join in the fun and explained the phenomenon he encountered and how to hack his way out of it. I hope you don't think that you are the only person who thought of the idea of using two different labels for the two loops! My approach wouldn't work on vectorizing computer where they use their own compiler-generated variables/registers for the DO-loop variables (usually they also state that changing the DO-loop variable inside the loop will not effect the execution of the loop if that's what they implement). However, I'm sure it will work in the way the original poster expected on his Appolo. (I love gambling so I almost always terminate my sentences with "wanna bet ?" but I guess I'd better refrain from it in this case. Etiquette is a real pain: It spoils all the fun !). I don't write program like like that and neither does the original poster (as was made obvious in his don't-flame-me remark) but why shouldn't we have some fun with it ? As I said, it would work with MOST computers that allow the construction but hey, this is obviously hacking and how can I guarantee a hack ?. Calvin Vu "Hackers have more fun!"