comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Protected types and visibility of their internals
Date: Thu, 10 Jul 2008 14:49:20 -0700 (PDT)
Date: 2008-07-10T14:49:20-07:00	[thread overview]
Message-ID: <8f1c5759-8b3a-45b5-8736-fecc63a71d0a@26g2000hsk.googlegroups.com> (raw)
In-Reply-To: g53jjv$mrr$1@jacob-sparre.dk

On 8 Lip, 23:03, "Randy Brukardt" <ra...@rrsoftware.com> 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:
>
>  package P2 is
>      type Priv is tagged limited private;
>      procedure Foo (Obj : in out Priv);
>  private
>     type Some_Type is ...
>     protected type PT is
>         procedure Foo;
>    private
>       X : Some_Type;
>    end PT;
>    type Priv is tagged limited record
>         Lock : PT;
>    end 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



  reply	other threads:[~2008-07-10 21:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-08  9:57 Protected types and visibility of their internals Maciej Sobczak
2008-07-08 12:52 ` Georg Bauhaus
2008-07-08 16:13 ` Robert A Duff
2008-07-09  7:53   ` christoph.grein
2008-07-08 21:03 ` Randy Brukardt
2008-07-10 21:49   ` Maciej Sobczak [this message]
2008-07-09  5:04 ` christoph.grein
2008-07-09 13:44   ` Maciej Sobczak
2008-07-09 15:12   ` Adam Beneschan
2008-07-09 22:19 ` Stephen Leake
2008-07-09 22:38   ` Adam Beneschan
2008-07-10  0:18     ` Randy Brukardt
2008-07-10  0:18     ` Randy Brukardt
2008-07-09 23:22 ` jimmaureenrogers
replies disabled

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