comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.de>
Subject: Re: subtypes and preconditions
Date: Tue, 21 Mar 2006 20:00:01 +0100
Date: 2006-03-21T19:59:54+01:00	[thread overview]
Message-ID: <44204d2a$0$7753$9b4e6d93@newsread4.arcor-online.net> (raw)
In-Reply-To: <eWWTf.876049$xm3.694350@attbi_s21>

Jeffrey R. Carter wrote:

> Yet I keep seeing
> examples that use preconditions rather than subtypes. For example,
> Barnes (2003) gives the example of Divide (p 70):
> 
> procedure Divide (M, N : in Integer; Q, R : out Integer);
> --# derives Q, R from M, N;
> --# pre (M >= 0) and (N > 0);
> --# post (M = Q * N + R) and (R < N) and (R >= 0);
> 
> rather than
> 
> procedure Divide (Dividend : in  Natural; Divisor   : in  Positive;
>                   Quotient : out Natural; Remainder : out Natural);
> --# derives Quotient, Remainder from Dividend, Divisor;
> --# post Dividend = Quotient * Divisor + Remainder and Remainder < Divisor;

WRT  M: Natural  versus  M: Integer >= 0, I think that in an
introductory example to reasoning about SPARK programs it
might in fact be good to leave out Ada subtypes' implications.

The reason is that you needn't know about the niceties of Ada's
subtypes in order to understand that M being >= 0 is important.
IOW, you already know what M >= 0 means, but you do not yet know
what M: Natural implies, unless you already know Ada.

_And_ you have to assume that Natural has not been redefined.
Redifining 0 is a lot more difficult :-)



Georg 



  reply	other threads:[~2006-03-21 19:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-20 13:31 subtype of enumeration type Maciej Sobczak
2006-03-20 14:26 ` Larry Kilgallen
2006-03-20 15:18   ` Maciej Sobczak
2006-03-20 15:37 ` Robert A Duff
2006-03-20 20:29 ` Björn Persson
2006-03-20 21:41 ` Jeffrey R. Carter
2006-03-21  8:37   ` subtypes and preconditions (was: subtype of enumeration type) Peter Amey
2006-03-21 17:42     ` subtypes and preconditions Jeffrey R. Carter
2006-03-21 19:00       ` Georg Bauhaus [this message]
2006-03-22  1:54         ` Jeffrey R. Carter
replies disabled

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