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: a07f3367d7,cb04cee6116c8ced X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-xxxfer.readnews.com!news-out.readnews.com!transit4.readnews.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Package's private parts and protected types Date: Tue, 09 Feb 2010 18:29:56 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7ff3810f-3ee3-4f39-a54c-933ad7d0655c@36g2000yqu.googlegroups.com> <1v2la97s2yyvd.1rcy0ana8mver.dlg@40tude.net> <3bb38996-47f7-4f30-8255-f011501404b5@b10g2000yqa.googlegroups.com> <4e959c35-34d1-49fb-b1eb-5b298e42610f@z19g2000yqk.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1265758185 25436 192.74.137.71 (9 Feb 2010 23:29:45 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 9 Feb 2010 23:29:45 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:5JnziCGZR8YgSNMm7ZnPfyP3eSE= Xref: g2news1.google.com comp.lang.ada:9055 Date: 2010-02-09T18:29:56-05:00 List-Id: "Hibou57 (Yannick Duch�ne)" writes: > Synchronized-and-the-like interface types are limited, so the built-in- > place is indeed really built-in-place (no kind of conversion allowed > at any stage). The initializer function have to return a class wide > and return it using an extended return statement which is required to > return the same exact type/subtype as the one function returns. > > This way of doing thing is not compatible with the implementation- > hiding requirement, as it would require the implementation type to be > exposed in the public part, so that I could define a public function > returning this exact type. I don't understand the problem. The following should work. Doesn't it do what you want? Type T exports Public, but hides Hidden. No heap allocation. package P is type T is synchronized interface; function Create return T'Class; procedure Public (X : in out T) is abstract; private protected type T2 is new T with overriding entry Public; entry Hidden; end T2; end P; package body P is function Create return T'Class is begin return Result : T2 do ... end return; end Create; protected body T2 is entry Public when ... is begin ... end Public; entry Hidden when ... is begin ... end Hidden; end T2; end P; with P; use P; procedure Main is X : T'Class := Create; begin Public (X); end Main; - Bob