comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Lorenzen <mark.lorenzen@gmail.com>
Subject: Re: SPARK: missing case value
Date: Fri, 9 Oct 2015 05:35:03 -0700 (PDT)
Date: 2015-10-09T05:35:03-07:00	[thread overview]
Message-ID: <9c3de690-e770-412e-b78f-4d254694ffcc@googlegroups.com> (raw)
In-Reply-To: <ad7b2827-9111-4d9b-b065-1ebd26795365@googlegroups.com>

On Friday, October 9, 2015 at 1:38:35 PM UTC+2, Maciej Sobczak wrote:
> On the other hand, SPARK is supposed to be a subset of Ada, so even if the above is feasible from the SPARK point of view, it should compile as regular Ada as well and compilers are not required to do this level of static analysis. So, SPARK does not do it, because Ada might not be able to keep the pace.
> 
> What are your thoughts on this?

I think it is logical and correct. How would a compiler be able to determine the range of E if your precondition was more complex?

I would change the case statement into something like this:

case E is
   when A => null;
   when B => null;
   when C => raise Impossible; -- or maybe Pragma Assert (False)
end case;

Note that you can use raise statements in SPARK as long as the program is still in SPARK i.e. the raise statement will never be executed.

Regards,

Mark L

  parent reply	other threads:[~2015-10-09 12:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 11:38 SPARK: missing case value Maciej Sobczak
2015-10-09 12:28 ` Stefan.Lucks
2015-10-09 12:35 ` Mark Lorenzen [this message]
2015-10-09 14:53   ` Bob Duff
2015-10-09 14:39 ` Bob Duff
2015-10-09 15:10   ` Dmitry A. Kazakov
2015-10-09 15:22     ` Bob Duff
2015-10-09 15:34       ` Dmitry A. Kazakov
2015-10-09 16:20     ` G.B.
2015-10-09 16:35       ` Dmitry A. Kazakov
2015-10-09 20:29         ` Georg Bauhaus
2015-10-09 21:01           ` Dmitry A. Kazakov
2015-10-10  6:44             ` Randy Brukardt
2015-10-10  9:10             ` Georg Bauhaus
2015-10-10 10:00               ` Dmitry A. Kazakov
2015-10-10 14:19                 ` Georg Bauhaus
2015-10-11  9:49                   ` Dmitry A. Kazakov
replies disabled

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