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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9da298537a16487e,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-10 14:20:14 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!csn!ncar!gatech!europa.eng.gtefsd.com!swiss.ans.net!butch!pong.lasc.lockheed.com!deepthought!tony From: tony@deepthought.Sgi.COM (Tony Leavitt) Newsgroups: comp.lang.ada Subject: Run-time checking and speed Date: 10 Jan 1995 22:20:14 GMT Organization: Silicon Graphics, Inc. Sender: tony@deepthought (Tony Leavitt) Distribution: world Message-ID: <3ev16u$ojc@pong.lasc.lockheed.com> NNTP-Posting-Host: deepthought.lasc.lockheed.com Date: 1995-01-10T22:20:14+00:00 List-Id: 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