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,66f9ac28e8d63f60 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!gegeweb.org!de-l.enfer-du-nord.net!news.weisnix.org!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 07 Sep 2009 19:01:12 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Enforcing initialization protocol for protected type References: <1fcccc80-0142-4f07-8852-8d151ea96ee2@c37g2000yqi.googlegroups.com> In-Reply-To: <1fcccc80-0142-4f07-8852-8d151ea96ee2@c37g2000yqi.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4aa53c59$0$30237$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 07 Sep 2009 19:01:13 CEST NNTP-Posting-Host: 219ae61a.newsspool1.arcor-online.net X-Trace: DXC=K Maciej Sobczak schrieb: > Consider the Needs_Constructor type from the code example in the Ada > wikibook: > > http://en.wikibooks.org/wiki/Ada_Programming/Types/limited#Initialisi... > > Is it possible to ensure a given initialization protocol for protected > types as well? The following is not using, I guess, your original idea directly. But it requires that the a proper context be set up. Then, the PO will initialize itself from the context. Context is passed in via known discriminants: -- method A, function pointer type Status_A is private; type A_Maker is access function return Status_A; -- method B, O-O construction type Status_B is private; package OO is type B_Maker is tagged private; function Make_B(Context: B_Maker) return Status_B; private type B_Maker is tagged record null; end record; end OO; type B_Maker_Ref is access OO.B_Maker'Class; protected type PO (First_A : not null A_Maker; First_B : not null B_Maker_Ref) is entry One; entry Two; private Data_A: Status_A := First_A.all; Data_B: Status_B := First_B.Make_B; end PO;