From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,146d9a693430fff2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Ada2012 Invariants and obaque types Date: Thu, 23 Jun 2011 16:21:03 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <239a78ad-0937-4a7a-8163-231430fd5ffe@k27g2000yqn.googlegroups.com> Reply-To: anon@anon.org NNTP-Posting-Host: bsHG8zUzEYajMmP2J6BwbQ.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: g2news2.google.com comp.lang.ada:20989 Date: 2011-06-23T16:21:03+00:00 List-Id: package P1 is type T1 is tagged private with Invariant => Is_Valid ( T1 ) ; function Create return T1 ; function Is_Valid ( This : T1 ) return Boolean ; private type Imp ; -- ???? Where is the completed type definition of "Imp" -- Another thing the syntax for Aspect Types may require -- that "Imp" be defined before T1, so "Imp" may be -- required in this example to be public. type T1 is tagged record -- ???? You forgot the keyword "tagged" I : Imp ; end record ; end P1 ; An Example of one that might work is from sem_ch13.ads package AspectVis is R_Size : constant Integer := 32; package Inner is type R is new Integer with Size => R_Size; F : R; -- freezes R_Size : constant Integer := 64; S : constant Integer := R'Size; -- 32 not 64 end Inner; end AspectVis; Check file Aspects.ads for a list of Aspects like "Invariant" In <239a78ad-0937-4a7a-8163-231430fd5ffe@k27g2000yqn.googlegroups.com>, Martin writes: >A fairly common Ada idiom is to define the full view of a private type >using an incomplete declaration. Thus leaving the actual >implementation to the package spec. Trying this out with the public >view defined with an invariant lead to a compiler error - is this: > >a) expected? >b) an unexpected consequence? or >c) a compiler bug? > >Example: >package P1 is > type T1 is tagged private > with Invariant => Is_Valid (T1); > function Create return T1; > function Is_Valid (This : T1) return Boolean; >private > type Imp; > type T1 is > record > I : Imp; > end record; >end P1; > >gnatmake -ws -c -u -PH:\Ada\test_invariants\test_invariants.gpr p1.ads >gcc -c -g -g -gnatE -gnatVn -gnato -fstack-check -gnat12 -gnatf -I- - >gnatA H:\Ada\test_invariants\src\p1.ads >p1.ads:11:04: type "Imp" is frozen at line 3 before its full >declaration >p1.ads:13:09: full declaration of private type "T1" defined at line 3 >must be a tagged type >p1.ads:15:14: invalid use of type before its full declaration >gnatmake: "H:\Ada\test_invariants\src\p1.ads" compilation error > >[2011-06-21 09:46:55] process exited with status 4 (elapsed time: >00.26s)