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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,eac70c5fad02d925 X-Google-Attributes: gidf891f,public X-Google-Thread: 101deb,c6e2c9477ddee2a6,start X-Google-Attributes: gid101deb,public X-Google-Thread: 1094ba,c6e2c9477ddee2a6,start X-Google-Attributes: gid1094ba,public X-Google-Thread: 103376,eac70c5fad02d925 X-Google-Attributes: gid103376,public From: rav@goanna.cs.rmit.EDU.AU (++ robin) Subject: Re: Concerning subscript bounds checks Date: 1996/06/25 Message-ID: <4qncnv$i94@goanna.cs.rmit.EDU.AU>#1/1 X-Deja-AN: 161936496 references: <4qdj3e$btf@goanna.cs.rmit.EDU.AU> organization: Comp Sci, RMIT, Melbourne, Australia keywords: subscripts newsgroups: comp.lang.ada,comp.lang.misc,comp.lang.pl1,comp.lang.fortran nntp-posting-user: rav Date: 1996-06-25T00:00:00+00:00 List-Id: ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe) writes: >There was some discussion in comp.lang.misc recently about array bounds >checks. As an exercise, I converted Algorithm AS 47 (an implementation >of the Nelder-Mead simplex minimisation procedure) from Fortran to Ada. >The Fortran original contains 85 array subscripts. >The Ada version contains 66 array subscripts. >Of these 66, all but 4 occur within the scope of a "for" loop >which *obviously* guarantees the safety of the subscript. ---I expect that the same observations could be made about re-writing the program in PL/I, or in Fortran 90. Why not post the original Fortran version, and the Ada translation, so we can see? >The remaining 4 occur in this context: > subtype Simplex_Range is Natural range 0 .. Point'Length; > P: "array (Simplex_Range) of ..." > Y: "array (Simplex_Range) of ..." > X: Point; > J: Simplex_Range; > ... > J := 0; -- at the start, J = Simplex_Range'First > for I in X'Range loop > ... > P(J) := ... > Y(J) := ... > J := J + 1; > end loop; -- at the end, J = Simplex_Range'Last > P(J) := ... > Y(J) := ... >end; >A reasonably smart compiler should be able to tell that these four >subscripts are also safe. >Fifty years of programming language research, and we end up with C++ ??? ---50 years? Wasn't Ada (after whom the language in which this posting also appeared first) the first programmer? Wouldn't that make it ~130 years? >Richard A. O'Keefe