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 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!news4.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 08 Jul 2008 14:52:29 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Protected types and visibility of their internals References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4873630e$0$6611$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 08 Jul 2008 14:52:30 CEST NNTP-Posting-Host: 0329a9c5.newsspool2.arcor-online.net X-Trace: DXC=6?0MoQKihWSU6b:FjPaGjQA9EHlD;3YcR4Fo<]lROoRQ8kF[nc\616M64>ZLh>_cHTX3j]]ITjS]POZcT X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:1038 Date: 2008-07-08T14:52:30+02:00 List-Id: 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