comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Processing array subsections, a newbie question.
Date: Sat, 12 Jun 2010 23:54:41 -0700
Date: 2010-06-12T23:54:41-07:00	[thread overview]
Message-ID: <hv1vfc$g7a$1@tornado.tornevall.net> (raw)
In-Reply-To: <87jc41FftrU1@mid.individual.net>

Niklas Holsti wrote:
> 
> if Index_Fst <= Buffer'Last then
>    -- Buffer is not empty, something to be done.
>    loop

OK, we get here with Index_Fst < Buffer'Last.

>       Do_Something(Buffer, Index_Fst, Index_Lst, Ok);

And Do_Something set Ok to True.

>       exit when not Ok;

Do_Something doesn't change Index_Fst, so we get past

>       exit when Index_Fst >= Buffer'Last;

to here. Now the OP's concern, IIUC, is that Index_Lst, which Do_Something sets, 
might be = Buffer'Last = Natural'Last (seems unlikely, but I suspect this is 
simplified from an example in which the index range is more constrained and 
Index_Lst is more likely to be = Index_Subtype'Last). In that case

>       Index_Fst := Index_Lst + 1;

will raise an exception.

So it looks to me as if the correct test is

exit when Index_Lst [>]= Buffer'Last;

(Maybe Brenta meant this, and mistyped it; the variable names are very similar. 
Using _First and _Last might make such an error more obvious.)

-- 
Jeff Carter
"Why don't you bore a hole in yourself and let the sap run out?"
Horse Feathers
49



  reply	other threads:[~2010-06-13  6:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-12 19:11 Processing array subsections, a newbie question Peter C. Chapin
2010-06-12 19:38 ` Yannick Duchêne (Hibou57)
2010-06-12 19:41 ` Yannick Duchêne (Hibou57)
2010-06-12 20:54 ` Ludovic Brenta
2010-06-13  1:20   ` Gene
2010-06-13 14:01     ` Peter C. Chapin
2010-06-13 15:48       ` Yannick Duchêne (Hibou57)
2010-06-13 16:57       ` Phil Thornley
2010-06-13 18:39         ` Yannick Duchêne (Hibou57)
2010-06-13 19:04           ` Phil Thornley
2010-06-13 18:58         ` Peter C. Chapin
2010-06-13  6:28   ` Niklas Holsti
2010-06-13  6:54     ` Jeffrey R. Carter [this message]
2010-06-16 19:03       ` Niklas Holsti
2010-06-16 19:22       ` Ludovic Brenta
2010-06-13 14:09     ` Peter C. Chapin
2010-06-13 11:00 ` Stephen Leake
2010-06-13 11:04   ` Simon Wright
2010-06-14  1:45     ` Stephen Leake
2010-06-14 18:23 ` Colin Paul Gloster
2010-06-14 19:41   ` Simon Wright
2010-06-14 23:54     ` Peter C. Chapin
2010-06-15  3:28       ` Jeffrey R. Carter
2010-06-15  6:13       ` Simon Wright
2010-06-15 11:24         ` Peter C. Chapin
2010-06-15  9:45       ` Phil Thornley
2010-06-15 11:27         ` Peter C. Chapin
2010-06-15 12:11           ` Yannick Duchêne (Hibou57)
replies disabled

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