From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4cb2c432feebd9d X-Google-Thread: 1094ba,c4cb2c432feebd9d X-Google-Attributes: gid103376,gid1094ba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!gnilink.net!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps82.POSTED!53ab2750!not-for-mail From: Gordon Sande Newsgroups: comp.lang.ada,comp.lang.fortran Message-ID: <2006052614490816807-gsande@worldnetattnet> References: <0ugu4e.4i7.ln@hunter.axlog.fr> <%P_cg.155733$eR6.26337@bgtnsc04-news.ops.worldnet.att.net> <6H9dg.10258$S7.9150@news-server.bigpond.net.au> <1hfv5wb.1x4ab1tbdzk7eN%nospam@see.signature> <4475DA61.3080001@comcast.net> <44762F55.4050106@cits1.stanford.edu> <87hd3d1472.fsf@ludovic-brenta.org> <3cBdg.6255$oa3.2407@trnddc08> <87ac9420s5.fsf@ludovic-brenta.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Bounds Check Overhead User-Agent: Unison/1.7.5 Date: Fri, 26 May 2006 17:49:09 GMT NNTP-Posting-Host: 24.89.210.20 X-Trace: edtnps82 1148665749 24.89.210.20 (Fri, 26 May 2006 11:49:09 MDT) NNTP-Posting-Date: Fri, 26 May 2006 11:49:09 MDT Xref: g2news2.google.com comp.lang.ada:4502 comp.lang.fortran:10299 Date: 2006-05-26T17:49:09+00:00 List-Id: On 2006-05-26 13:44:58 -0300, Ludovic Brenta said: > Rich Townsend writes: >> Dick Hendrickson wrote: >>> Given something like >>> COMMON I >>> DO I = 1,10 >>> call something (I) >>> call something_else() >>> enddo >>> "something" is not allowed to change it's argument and neither >>> "something" nor "something_else" is allowed to change the variable >>> in common. This prohibition flows down the entire call tree from >>> these routines. And that's why it's hard to check. >> >> ...although a lot of the constructs introduced in Fortran 90 help in >> checking -- in particular, if the called subroutines have INTENT() >> on their arguments, then its pretty cut-and-dry whether I will be >> modified or not. Having said that, things like host association can >> muddy the waters somewhat -- but at least you only have to go down >> one level to check if I is being modified. > > Then Ada is better in that respect than Fortran. In Ada, the compiler > has enough knowledge about what subprograms do to their arguments that > it can easily check that loop indexes never change (i.e. you can pass > the loop index as an "in" parameter but not as an "out" or "in out" > parameter). > Also, in Ada, the loop index does not exist outside of the loop. From > what you said, it seems to me that in Fortran, the loop index still > exists after the loop, and has a well-defined value, but the > programmer can then change it. Correct? Many search idioms use the fact that a DO index is just another integer variable which will have a known value on a forced exit from the loop. It also has a known value when the loop terminates naturally. The index is the exclusive property of the DO inside the loop but it is visible to the rest of the program. Being an integer is a new restriction. The contract that the programmer has with the compiler is that the index will not be tampered with. The checking that many systems do is not exhaustive and proveably correct. It just grumbles about the obvious cases. If one use F90 well then the compiler will catch many more cases. Too many folks in a hurry (and who know they never make mistakes) do not bother (so they spend more time debugging and blaming the hardware or compiler). In olden times of F66 there was a long contorted notion of first and second level definition to account for the fact that a DO index was likely to be in a hardware register and compiler technology was not developed to do much checking. It was more documentation of the quirks that had been discovered in the early compilers. That is long since past but some echoes survive. The Ada constructs would require that one explicitly capture the loop index on forced exit and do whatever else is required to notice a natural termination. If the index was to be used in any way other than as an arguement then one would have to explicitly copy it. One gets used to whatever idioms are required. After a while they look natural. There have been more than a few suggested syntaxes for loops and searches. This is not a topic devoid of extensive discussion.