comp.lang.ada
 help / color / mirror / Atom feed
From: tony@deepthought.Sgi.COM (Tony Leavitt)
Subject: Run-time checking and speed
Date: 10 Jan 1995 22:20:14 GMT
Date: 1995-01-10T22:20:14+00:00	[thread overview]
Message-ID: <3ev16u$ojc@pong.lasc.lockheed.com> (raw)

I have a question about developing Ada code that still has all of
its normal run-time checking and is "fast."  Is there an execution
difference with repsect to run-time checking in any of the following.
Or, is there "a good real-time style" for this type of stuff? 



-- CASE 1
-- This case seems to need all of the full run-time checking since
-- the variables x and y can be unlimited when accessing the array.

XY_array : array (integer range 1..100, integer range 1..100) of float ;

for x in 1..100 loop
  for y in 1..100 loop
     XY_array(x,y) := calc_something  ;
   end loop ;
end loop ;



-- CASE 2
-- This case it seems that no runtime checking is needed when
-- accessing the array since x and y are, by definition, within
-- the array bounds (assuming memory doesn't go bad while running).

subtype arraybounds is integer range 1..100 ;

XY_array : array (arraybounds, arraybounds) of float ;

for x in arraybounds loop
  for y in arraybounds loop
     XY_array(x,y) := calc_something  ;
   end loop ;
end loop ;



-- CASE 3
-- This seems similar to CASE 2

XY_array : array (integer range 1..100, integer range 1..100) of float ;

for x in XY_array'Range(1) loop
  for y in XY_array'Range(2) loop
     XY_array(x,y) := calc_something  ;
   end loop ;
end loop ;




I've used loops since they are simple, but other issues are the same.
For example, I could have a function compute the array indices and return
either integers or arraybounds.  If I return arraybounds, it seems that
the run-time check would occur at assigning the arraybounds and not when
accessing the array.

TIA,

-- 

Tony Leavitt

Email: tony@gelac.lasc.lockheed.com



             reply	other threads:[~1995-01-10 22:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-01-10 22:20 Tony Leavitt [this message]
1995-01-12  1:14 ` Run-time checking and speed Roger Labbe
1995-01-13 12:09   ` Philip Brashear
     [not found] ` <3f0prq$3bq@theopolis.orl.mmc.com>
1995-01-12 14:13   ` Robert Dewar
1995-01-13  1:49     ` Doug Smith
1995-01-13 15:29       ` Norman H. Cohen
1995-01-13 15:21     ` Norman H. Cohen
     [not found]     ` <3fa2pk$kbi@felix.seas.gwu.edu>
     [not found]       ` <EACHUS.95Jan17151835@spectre.mitre.org>
     [not found]         ` <3fjhrj$9b3@oahu.cs.ucla.edu>
1995-01-20  5:11           ` Robert Dewar
1995-01-23 16:43             ` Mats Weber
1995-01-24 19:25               ` Robert Dewar
1995-01-22 18:43         ` Michael Feldman
1995-01-23 23:38           ` Robert Dewar
1995-01-26 16:14             ` Kent Mitchell
1995-01-28  6:03               ` Robert Dewar
     [not found]             ` <3gbr4f$p4b@theopolis.orl.mmc.com>
1995-01-29 13:00               ` Robert Dewar
1995-01-30 19:21                 ` Garlington KE
1995-01-12 15:11 ` Norman H. Cohen
  -- strict thread matches above, loose matches on Subject: below --
1995-01-12 15:54 Keith Arthurs
replies disabled

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