From: Victor Porton <porton@narod.ru>
Subject: Re: Type invariants and private extensions?
Date: Tue, 12 Sep 2017 01:02:59 +0300
Date: 2017-09-12T01:02:59+03:00 [thread overview]
Message-ID: <op716t$11gs$1@gioia.aioe.org> (raw)
In-Reply-To: ec2642af-9b8e-49a8-a797-f0d56498d786@googlegroups.com
Isn't it a good idea to modify the RM to allow type invariants also for
derived types with null records?
Jere wrote:
> On Monday, September 11, 2017 at 5:27:54 PM UTC-4, Victor Porton wrote:
>> Egil H H wrote:
>>
>> > On Monday, September 11, 2017 at 10:48:46 PM UTC+2, Victor Porton
>> > wrote:
>> >> > The Invariant will then be inherited by all derived types
>> >>
>> >> It is not what I want. I want different invariants for different
>> >> derived types.
>> >>
>> >
>> > You can add new invariants in addition to the ones inherited
>>
>> I cannot: the compiler gives an error:
>>
>> package P is
>>
>> type T is tagged private;
>>
>> private
>>
>> type T is tagged null record;
>>
>> end P;
>>
>> with P; use P;
>>
>> package P1 is
>>
>> type T1 is new T with null record
>> with Type_Invariant => True;
>>
>> end P1;
>>
>>
>> $ gnatgcc -gnatc -c p1.ads
>> p1.ads:6:10: aspect "Type_Invariant" only allowed for private type or
>> corresponding full view
>>
>> --
>> Victor Porton - http://portonvictor.org
>
> You aren't applying it to a private type. Try:
>
> package P1 is
>
> type T1 is new T with private
> with Type_Invariant'Class => True;
>
> private
>
> type T1 is new T with null record;
>
>
> end P1;
>
> The relevant RM section:
>
> 7.3.2
>
> 2/3
> Type_Invariant
>
> This aspect shall be specified by an expression, called an
> invariant expression. Type_Invariant may be specified on a
> private_type_declaration, on a private_extension_declaration,
> or on a full_type_declaration that declares the completion of
> a private type or private extension.
>
> 3/3
> Type_Invariant'Class
>
> This aspect shall be specified by an expression, called an
> invariant expression. Type_Invariant'Class may be specified
> on a private_type_declaration or a private_extension_declaration.
--
Victor Porton - http://portonvictor.org
next prev parent reply other threads:[~2017-09-11 22:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 19:51 Type invariants and private extensions? Victor Porton
2017-09-11 20:00 ` Egil H H
2017-09-11 20:48 ` Victor Porton
2017-09-11 21:19 ` Egil H H
2017-09-11 21:27 ` Victor Porton
2017-09-11 21:49 ` Egil H H
2017-09-11 22:00 ` Victor Porton
2017-09-11 22:06 ` Egil H H
2017-09-12 7:30 ` Dmitry A. Kazakov
2017-09-11 22:00 ` Jere
2017-09-11 22:02 ` Victor Porton [this message]
2017-09-12 18:26 ` Jeffrey R. Carter
2017-09-12 18:54 ` Victor Porton
2017-09-12 19:56 ` Jeffrey R. Carter
2017-09-12 20:08 ` Victor Porton
2017-09-12 22:34 ` Shark8
2017-09-12 22:59 ` Victor Porton
2017-09-13 4:21 ` Jere
2017-09-13 4:28 ` Jere
2017-09-13 4:34 ` Jere
2017-09-14 13:52 ` Victor Porton
2017-09-15 0:48 ` Jere
2017-09-16 14:22 ` Victor Porton
2017-09-14 7:28 ` Shark8
2017-09-14 13:56 ` Victor Porton
2017-09-14 13:58 ` Victor Porton
2017-09-11 22:48 ` Shark8
2017-10-02 23:16 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox