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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d4e2f238dc61c890 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!26g2000hsk.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Protected types and visibility of their internals Date: Thu, 10 Jul 2008 14:49:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8f1c5759-8b3a-45b5-8736-fecc63a71d0a@26g2000hsk.googlegroups.com> References: NNTP-Posting-Host: 85.3.246.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1215726561 19391 127.0.0.1 (10 Jul 2008 21:49:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Jul 2008 21:49:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 26g2000hsk.googlegroups.com; posting-host=85.3.246.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1096 Date: 2008-07-10T14:49:20-07:00 List-Id: On 8 Lip, 23:03, "Randy Brukardt" wrote: > I think you are asking the wrong question. The question is "Where should = the > protected type be declared?". Since there are no operations that are > specific to protected types, there is very little reason to make those a > visible type. > > Thus, I would generally structure the package with a private type and the > protected type (if any) declared in the private part. Something like: > > =A0package P2 is > =A0 =A0 =A0type Priv is tagged limited private; > =A0 =A0 =A0procedure Foo (Obj : in out Priv); > =A0private > =A0 =A0 type Some_Type is ... > =A0 =A0 protected type PT is > =A0 =A0 =A0 =A0 procedure Foo; > =A0 =A0private > =A0 =A0 =A0 X : Some_Type; > =A0 =A0end PT; > =A0 =A0type Priv is tagged limited record > =A0 =A0 =A0 =A0 Lock : PT; > =A0 =A0end record; > end P2; Yes, it works for me. In addition, this allowed me to hide some additional operations of the protected type, which are not supposed to be used by public, but are necessary in interactions with other components. Putting the whole protected type in private part of the package is a clean way to do this. "Every computing problem can be solved with additional level of indirection." :-) -- Maciej Sobczak * www.msobczak.com * www.inspirel.com