From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Protected types and visibility of their internals
Date: Tue, 08 Jul 2008 14:52:29 +0200
Date: 2008-07-08T14:52:30+02:00 [thread overview]
Message-ID: <4873630e$0$6611$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <b1f2203b-ed02-4031-bcba-40c0e1b1be07@j22g2000hsf.googlegroups.com>
Maciej Sobczak schrieb:
> Consider a protected type in some package:
>
> package P is
> protected type PT is
> procedure Foo;
> private
> X : Some_Type;
> end PT;
> end P;
> ...
> Can you recommend some other solution that enforces strict coding
> practice?
I'm assuming you want clients to consider PT some synchronized
abstract data type? Using Ada 83, a passive task might have
worked :-) Using Ada 95, I'd consider moving the protected
type to the body, and provide procedural wrappers.
Using current Ada, the following might work, though
I have probably made a few grammatical mistakes in a rush;
all GNATs crash on this is some way or other:
package News21 is
type Only_Ops is synchronized interface;
procedure Foo(It: in out Only_Ops) is abstract;
type PT is limited new Only_Ops with private;
private
type Some_Type is null record;
protected type PT is new Only_Ops with
overriding
procedure Foo;
private
X : Some_Type;
end PT;
end News21;
--
Georg Bauhaus
Y A Time Drain http://www.9toX.de
next prev parent reply other threads:[~2008-07-08 12:52 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 [this message]
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
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