comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Making guarantees about record components
Date: Wed, 20 Nov 2013 03:36:50 -0600
Date: 2013-11-20T03:36:50-06:00	[thread overview]
Message-ID: <8561rnwh1p.fsf@stephe-leake.org> (raw)
In-Reply-To: l6gqci$lrk$1@dont-email.me

Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> On 11/19/2013 11:49 AM, J Kimball wrote:
>>
>> I'm trying to guarantee that two record component values map to the same
>> value of another type.
>>
>> type A is (...);
>> type C is (...);
>>
>> M : array (A) of C := (...);
>>
>> type R is record
>>     A1 : A;
>>     A2 : A;
>> end record
>>     with Dynamic_Predicate => (M (R.A1) = M (R.A2) );
>>
>> Is this the best solution we have as of Ada 2012?
>
> If you really want to guarantee that the property always holds, this
> doesn't do that. Changes to components of variables of type R, and
> changes to M, may invalidate the predicate but not be detected until
> later. To really guarantee the property, you'd have to encapsulate M
> and all instances of R so that all such changes can be checked.

The rules for when the Dynamic_Predicate is checked are in LRM 3.2.3
31/3. To me, that says any changes to an object of type R are checked,
but not changes to M. 

There is no value for M that satisfies this constraint for all possible
values of R, so this does not seem like a well-defined problem.

I think you need a private type hiding both R and M to enforce this
constraint.

-- 
-- Stephe

  reply	other threads:[~2013-11-20  9:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 18:49 Making guarantees about record components J Kimball
2013-11-19 20:20 ` Anh Vo
2013-11-19 22:57 ` Jeffrey Carter
2013-11-20  9:36   ` Stephen Leake [this message]
2013-11-20 17:37     ` Jeffrey Carter
2013-11-21  6:53       ` Stephen Leake
2013-11-20 20:58   ` tmoran
2013-11-19 23:38 ` Shark8
2013-11-20  8:01   ` Dmitry A. Kazakov
2013-11-22  5:46 ` J Kimball
replies disabled

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