From: Martin <martin@thedowies.com>
Subject: Re: Weird error with Dynamic_Predicate
Date: Tue, 13 May 2014 10:04:34 -0700 (PDT)
Date: 2014-05-13T10:04:34-07:00 [thread overview]
Message-ID: <e0aa07b0-e464-48de-b35e-ea26767da710@googlegroups.com> (raw)
In-Reply-To: <5372142e$0$6603$9b4e6d93@newsspool4.arcor-online.net>
On Tuesday, May 13, 2014 1:46:39 PM UTC+1, G.B. wrote:
> On 12.05.14 21:47, mockturtle wrote:
>
> > Any ideas?
>
>
>
> From a different angle, a rule of contract-based design---
>
> assuming the lessons learned from DbC---is not a substitute
>
> for input checking. While I guess you have your reasons for
>
> attaching the Dynamic_Predicate to a string type, if you
>
> are preforming proofs, which DbC would oblige you to do,
>
> there is a different strategy:
>
>
>
> By the above rule (about DbC not being input checking),
>
> some I/O routine would check the syntax;
>
> then, if the characters form a well formed string, the object
>
> can be converted to a different string type; this string
>
> type does not have the dynamic check attached, since after
>
> the checking routine is done, the type's objects are known
>
> to have only good values.
Right, it should be the 'constructor' that ensures the class invariant - the validity of the 'raw string' or raises an exception otherwise.
So you always want to force the user to use a proved 'constructor' function and no other, e.g.
package Valid_Strings is
type Valid_String (<>) is tagged private;
Invalid_String : exception;
function Create (S : String) return Valid_String; -- or Invalid_String
private
type Valid_String is tagged record
...
end record;
...
end Valid_Strings;
-- Martin
next prev parent reply other threads:[~2014-05-13 17:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 19:47 Weird error with Dynamic_Predicate mockturtle
2014-05-12 20:45 ` Peter Chapin
2014-05-12 20:52 ` mockturtle
2014-05-12 21:01 ` Adam Beneschan
2014-05-12 22:17 ` Randy Brukardt
2014-05-13 4:40 ` Simon Wright
2014-05-13 20:50 ` Simon Wright
2014-05-13 4:59 ` Shark8
2014-05-13 12:46 ` G.B.
2014-05-13 17:04 ` Martin [this message]
2014-05-13 18:55 ` mockturtle
2014-05-13 21:39 ` Georg Bauhaus
2014-05-14 7:30 ` mockturtle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox