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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Ada2012 Invariants and obaque types Date: Tue, 21 Jun 2011 12:27:56 +0200 Organization: Ada @ Home Message-ID: References: <239a78ad-0937-4a7a-8163-231430fd5ffe@k27g2000yqn.googlegroups.com> NNTP-Posting-Host: yX6LbLzlJbxneowXz9IDkg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.11 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:19969 Date: 2011-06-21T12:27:56+02:00 List-Id: Hi Martin, Unless I've missed something, I do not see the point. Whether or not you= = use an invariant, if the public view assert the type is tagged, the full= = view must be tagged. This was the same, even prior to Ada 2012. Otherwis= e, = how would you derive from a tagged public view and define class wide vie= w, = from a type whose private view isn't tagged ? Just out of curiosity: which GNAT flavor do you use for Ada 2012 ? Le Tue, 21 Jun 2011 10:53:31 +0200, Martin = a =C3=A9crit: > 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 =3D> 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) -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [Ep= igrams on = Programming =E2=80=94 Alan J. =E2=80=94 P. Yale University] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [Idem] Java: Write once, Never revisit