comp.lang.ada
 help / color / mirror / Atom feed
From: rav@goanna.cs.rmit.EDU.AU (++           robin)
Subject: Re: Concerning subscript bounds checks
Date: 1996/06/25
Date: 1996-06-25T00:00:00+00:00	[thread overview]
Message-ID: <4qncnv$i94@goanna.cs.rmit.EDU.AU> (raw)
In-Reply-To: 4qdj3e$btf@goanna.cs.rmit.EDU.AU


	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




  parent reply	other threads:[~1996-06-25  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-21  0:00 Concerning subscript bounds checks Richard A. O'Keefe
1996-06-21  0:00 ` Robert Dewar
1996-06-24  0:00   ` Adam Beneschan
1996-06-24  0:00   ` William Clodius
1996-06-27  0:00     ` Richard A. O'Keefe
1996-06-28  0:00       ` Ken Thomas
1996-06-24  0:00   ` Richard A. O'Keefe
1996-06-24  0:00     ` Robert Dewar
1996-06-28  0:00     ` joeuser
1996-06-28  0:00       ` Adam Beneschan
1996-07-01  0:00       ` Richard A. O'Keefe
1996-07-01  0:00         ` Robert A Duff
1996-07-02  0:00           ` Richard A. O'Keefe
1996-06-25  0:00 ` William Clodius
1996-06-25  0:00 ` ++           robin [this message]
1996-06-27  0:00   ` Richard A. O'Keefe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox