comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Re: Preconditions which anyway would be caught?
Date: Sat, 9 Aug 2014 08:40:49 -0700 (PDT)
Date: 2014-08-09T08:40:49-07:00	[thread overview]
Message-ID: <89bfed98-c656-45b5-b812-5fd9c7d5998e@googlegroups.com> (raw)
In-Reply-To: <ls5f3l$4t8$1@speranza.aioe.org>

On Saturday, August 9, 2014 5:35:21 PM UTC+2, Victor Porton wrote:
> function Inverse (X: Float) is
> 
> begin
>    return 1/X;
> end
>    with Pre => (X /= 0);
> 
> Is this precondition superfluous? (it anyway could be caught by erroneous 
> 1/X operation)

Still not a LL... I would say it is not.  It depends on the "reason" for specifying the precondition.  As I see it, the precondition is a kind of "formal documentation" of the conditions that must be satisfied when you call the function.  As a side effect, you can have those conditions checked at run-time as a "bug trap," but, for example, they could be used by some formal checking software.  So, even if calling the function with X=0 will cause an error, I would keep the precondition.

Riccardo



  reply	other threads:[~2014-08-09 15:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-09 15:35 Preconditions which anyway would be caught? Victor Porton
2014-08-09 15:40 ` mockturtle [this message]
2014-08-09 16:08 ` Jeffrey Carter
2014-08-09 19:21 ` Peter Chapin
2014-08-09 19:24   ` Peter Chapin
2014-08-09 21:04     ` Niklas Holsti
2014-08-09 22:57       ` Peter Chapin
2014-08-10 20:58         ` Niklas Holsti
2014-08-10  7:24       ` Dmitry A. Kazakov
2014-08-11  0:00         ` Shark8
2014-08-11  7:31           ` 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