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, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d4e2f238dc61c890 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!postnews.google.com!34g2000hsf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Protected types and visibility of their internals Date: Wed, 9 Jul 2008 15:38:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1215643128 8371 127.0.0.1 (9 Jul 2008 22:38:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 Jul 2008 22:38:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 34g2000hsf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1061 Date: 2008-07-09T15:38:48-07:00 List-Id: On Jul 9, 3:19 pm, Stephen Leake wrote: > Maciej Sobczak writes: > > Consider a protected type in some package: > > > package P is > > protected type PT is > > procedure Foo; > > private > > X : Some_Type; > > end PT; > > end P; > > > The protected type has a component X of Some_Type, which is entirely > > the private business of the protected type. > > > Where this type should be declared? > > In a sibling private package: > > private > package P.stuff is > > type Some_Type is ...; > end P.Stuff; > > private with P.stuff; > package P is > protected type PT is > procedure Foo; > private > X : P.Stuff.Some_Type; > end PT; > end P; > > Hmm. Maybe that's not right, since P.Stuff is used in the private part > of a public type, not strictly in the private part of P. But it > _should_ be ok! It appears that private parts of protected types *can* use things declared in packages mentioned with "private with". However, your example won't work because you can't have the specification of P "with" a child of P; this creates a circular dependency. You *could* do this, however: private with P.Stuff; package P.Stuff2 is protected type PT is procedure Foo; private X : P.Stuff.Some_Type; end PT; end P.Stuff2; This still won't solve Maciej's problem if the definition of Some_Type requires some other types declared earlier in Stuff2. If that's the case, he'll have to reorganize things yet further and move some of those types to yet another package, Stuff3. It does seem like there ought to be a better way to accomplish all this---how about letting private and public parts of a package spec be interspersed? package P is private type Some_Type is ... not private -- heh, heh, heh! protected type PT is procedure Foo; private X : Some_Type; end PT; private .. other private stuff can go here if needed end P; But any solution is likely to be a huge burden on both the language designers and implementors, at this point. I think we're stuck. -- Adam