comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Ada2012 Invariants and obaque types
Date: Tue, 21 Jun 2011 03:36:48 -0700 (PDT)
Date: 2011-06-21T03:36:48-07:00	[thread overview]
Message-ID: <b57c429a-81ed-4694-a8d9-c7609e2ede72@s17g2000yqs.googlegroups.com> (raw)
In-Reply-To: op.vxe8oupoule2fv@douda-yannick

On Jun 21, 11:27 am, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> 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. Otherwise,  
> how would you derive from a tagged public view and define class wide view,  
>  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 <martin.do...@btopenworld.com>  
> a écrit:
>
>
>
>
>
>
>
>
>
> > 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)
>
> --
> “Syntactic sugar causes cancer of the semi-colons.”  [Epigrams on  
> Programming — Alan J. — P. Yale University]
> “Structured Programming supports the law of the excluded muddle.” [Idem]
> Java: Write once, Never revisit

Sorry - the pearls of doing a 'quick' demo...

Replace "type T1 is" with " type T1 is tagged"

and you still get:

> > p1.ads:11:04: type "Imp" is frozen at line 3 before its full
> > declaration
> > p1.ads:15:14: invalid use of type before its full declaration
> > gnatmake: "H:\Ada\test_invariants\src\p1.ads" compilation error

Which is the really what I'm asking about...

-- Martin



  reply	other threads:[~2011-06-21 10:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21  8:53 Ada2012 Invariants and obaque types Martin
2011-06-21 10:27 ` Yannick Duchêne (Hibou57)
2011-06-21 10:36   ` Martin [this message]
2011-06-21 10:46   ` Martin
2011-06-21 18:42     ` Yannick Duchêne (Hibou57)
2011-06-21 10:43 ` Ludovic Brenta
2011-06-21 10:53   ` Martin
2011-06-21 11:14 ` Martin
2011-06-21 11:31 ` Robert A Duff
2011-06-21 11:48   ` Martin
2011-06-21 12:01   ` Martin
2011-06-21 12:13     ` Robert A Duff
2011-06-21 12:22       ` Martin
2011-06-21 12:54         ` Robert A Duff
2011-06-21 13:00           ` Martin
2011-06-21 12:08 ` Dmitry A. Kazakov
2011-06-21 12:17   ` Georg Bauhaus
2011-06-21 12:31     ` Dmitry A. Kazakov
2011-06-21 13:29       ` Georg Bauhaus
2011-06-21 14:42         ` Dmitry A. Kazakov
2011-06-21 18:37   ` Yannick Duchêne (Hibou57)
2011-06-21 18:53     ` Dmitry A. Kazakov
2011-06-21 19:34       ` Vinzent Hoefler
2011-06-21 20:52         ` Dmitry A. Kazakov
2011-06-21 21:50           ` Vinzent Hoefler
2011-06-22  7:55             ` Dmitry A. Kazakov
2011-06-21 21:18       ` Manuel Collado
2011-06-22  8:00         ` Dmitry A. Kazakov
2011-06-22 10:39 ` Egil Høvik
2011-06-22 13:57   ` Martin
2011-06-23 16:21 ` anon
replies disabled

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