From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Hi-Lite high integrity showcase and overflow errors
Date: Tue, 04 Sep 2012 10:30:49 +0200
Date: 2012-09-04T10:30:49+02:00 [thread overview]
Message-ID: <5045bc39$0$6569$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <f9c3420e-7959-4ddf-b61c-d0eabbfdd197@googlegroups.com>
On 04.09.12 05:05, Shark8 wrote:
> function Mult (X , Y : My_Int) return My_Int is
> begin
> Return Result : My_Int do
> Result:= X*Y;
>
> -- When the constraint is exceeded we return the last value.
> exception
> when Constraint_Error =>
> Result:= My_Int'Last;
> End Return;
> end Mult;
>
Part of the exercise (which also mentions SPARK) is to have
programs that can drop support for exception handling, I should think.
Formally verified etc etc. So, no, this won't fly ;-)
When McJones & Stepanov introduced the idea behind their recent book
Stepanov has McJones put up a slide, titled "Respect the Domain", which
involves the quantity 2*b. The following lines are taken from near
00:41:45 of http://www.youtube.com/watch?v=Ih9gpJga4Vc:
// Precondition: a ≥ b > 0
if (a - b >= b) { //! Not: a >= b + b
He points out that programmers need to work with potentially partial
functions; "+" is not everywhere defined; it can overflow.
We have to guard as in the Precondition, and "therefore, we could
subtract", even when most mathematicians would say this is stupid
(the meaning of the call-out bubble starting with //! above), which
it isn't because b + b might require more bits than are available.
That's much like X op Y in Hi-Lite's Mult/Add conditionals,
isn't it?
next prev parent reply other threads:[~2012-09-12 15:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 21:56 Hi-Lite high integrity showcase and overflow errors Georg Bauhaus
2012-09-04 2:53 ` Shark8
2012-09-04 3:05 ` Shark8
2012-09-04 8:30 ` Georg Bauhaus [this message]
2012-09-04 18:45 ` Shark8
2012-09-04 20:21 ` Florian Weimer
2012-09-04 21:24 ` Shark8
2012-09-05 9:25 ` yannick.moy
2012-09-05 9:19 ` yannick.moy
2012-09-05 11:15 ` Georg Bauhaus
2012-10-03 10:47 ` Florian Weimer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox