comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: Processing array subsections, a newbie question.
Date: Sun, 13 Jun 2010 09:57:14 -0700 (PDT)
Date: 2010-06-13T09:57:14-07:00	[thread overview]
Message-ID: <e6411932-94a1-452d-9211-d80dfe3a3d8e@z10g2000yqb.googlegroups.com> (raw)
In-Reply-To: 4c14e3fd$0$2382$4d3efbfe@news.sover.net

On 13 June, 15:01, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
[...]
> Thanks for the suggestion (by you and others) for using a loop exit. SPARK has
> some restrictions on how 'exit' can be used; I'm not sure if they will apply
> to my case or not, but I can look into it. In my case there is also a state
> machine involved and the exiting would have to take place inside a case
> statement inside the loop. I seem to recall that SPARK has an issue with
> exiting from nested control structures but I can experiment.

I don't think the state machine will make any difference, but you
certainly can't exit an enclosing loop when in a case arm - you have
to move the exit(s) to after the 'end case'.

This is not usually too much of a problem, but in your code it forces
the exit to come after the increment (assuming that this has to stay
in the case arm).

As you suggest elsewhere in this thread, it is a good idea to have
subtype constraints as tight as possible.  In the situation you
describe I would define a type (to replace your use of Natural) that
has one extra value at the end (for the Index_Fst variable).  Then
define the array index as a subtype that excludes that extra value.
This should allow the increment to stay in the case arm, with the exit
following after the case.

(BTW, if you haven't tried it yet, you will find that using
unconstrained arrays creates additional work when doing run-time
checks as the VCs generated by any reference to an array element use
the limits for that array object, not just the array index subtype).

Cheers,

Phil



  parent reply	other threads:[~2010-06-13 16:57 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 [this message]
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
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