comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: SPARK code samples
Date: Thu, 12 Aug 2010 00:29:22 -0700 (PDT)
Date: 2010-08-12T00:29:22-07:00	[thread overview]
Message-ID: <b4682a96-9b38-49c1-a2e1-4b3580cc120a@q22g2000yqm.googlegroups.com> (raw)
In-Reply-To: op.vha0bzhexmjfy8@garhos

On 12 Sie, 04:39, Yannick Duchêne (Hibou57) <yannick_duch...@yahoo.fr>
wrote:

> * I could have made a test to ensure inputs of A and B is in -1000..+1000,  
> while this would not avoid the need to check for the sum validity, as  
> formally speaking there is no way to assert anything on Integer range.  
> Second reason to dropped this assumption. OK ?

No. AARM 3.5.4/21 defines the minimum range for Integer, it is
-2**15+1..2**15-1.

Since SPARK is supposed to be compilable as a valid Ada, then its
implementation ranges cannot be smaller than those required for Ada
and therefore you can safely assume that if A and B are within
-1000..1000, then their sum will fit within Integer (their product
might not).

That will reduce the code significantly.

I also think that if the program requirements say that the input will
be in some range, you can assume this is true without asserting it.
The point is that such requirements are verifiable outside of the
program, for example by the design of subsystem (hardware data source,
perhaps?) that feeds input to your component.
Another argument might be the following: if you are not comfortable
assuming that input is in the range defined externally, then why do
you assume that the reaction of your program (printing English prose)
will be valid in that same environment? The environment is not
necessarily an English-speaking human sitting in front of the screen -
especially in the case of SPARK programs. ;-)

--
Maciej Sobczak * http://www.inspirel.com

YAMI4 - Messaging Solution for Distributed Systems
http://www.inspirel.com/yami4



  parent reply	other threads:[~2010-08-12  7:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11  8:44 SPARK code samples Dmitry A. Kazakov
2010-08-11 11:38 ` Ada novice
2010-08-11 13:54   ` Yannick Duchêne (Hibou57)
2010-08-11 16:07   ` Mark Lorenzen
2010-08-11 16:33     ` (see below)
2010-08-11 16:45     ` Yannick Duchêne (Hibou57)
2010-08-11 16:50       ` Yannick Duchêne (Hibou57)
2010-08-11 17:10       ` Ada novice
2010-08-11 18:21         ` Yannick Duchêne (Hibou57)
2010-08-12 12:08           ` Ada novice
2010-08-12 22:03             ` Phil Thornley
2010-08-11 15:26 ` Yannick Duchêne (Hibou57)
2010-08-11 17:33   ` Dmitry A. Kazakov
2010-08-12  2:39     ` Yannick Duchêne (Hibou57)
2010-08-12  5:02       ` Jeffrey Carter
2010-08-12 13:31         ` Yannick Duchêne (Hibou57)
2010-08-12  7:16       ` cjpsimon
2010-08-12  7:29       ` Maciej Sobczak [this message]
2010-08-12 13:41         ` Yannick Duchêne (Hibou57)
2010-08-12  9:46       ` Jacob Sparre Andersen
2010-08-12 13:43         ` Yannick Duchêne (Hibou57)
2010-08-12 13:58           ` Jacob Sparre Andersen
2010-08-12  3:03     ` Yannick Duchêne (Hibou57)
  -- strict thread matches above, loose matches on Subject: below --
2010-08-11 17:32 Mark Lorenzen
2010-08-11 17:39 ` Ada novice
2010-08-11 17:45   ` (see below)
2010-08-11 18:00     ` Ada novice
2010-08-11 18:17       ` 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