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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0f4738b8e27cca3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-25 08:50:48 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsgate.cistron.nl!skynet.be!skynet.be!louie!tjb!not-for-mail Sender: lbrenta@lbrenta Newsgroups: comp.lang.ada Subject: Re: Problem with protected type References: From: Ludovic Brenta User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Date: 25 Nov 2003 17:45:17 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 217.136.19.61 X-Trace: 1069778718 reader3.news.skynet.be 27404 217.136.19.61:38050 X-Complaints-To: usenet-abuse@skynet.be Xref: archiver1.google.com comp.lang.ada:2927 Date: 2003-11-25T17:45:17+01:00 List-Id: "Ekkehard Morgenstern" writes: > I solved the problem by using a class-wide type access and an init > procedure: > > type CoreEvent is tagged private; > type CoreEvent_Ptr is access all CoreEvent'Class; > > function CreateCoreEvent return CoreEvent_Ptr; > > protected BaseEvent is > procedure Init; > entry Wait; > procedure Signal; > procedure ManualMode; > procedure AutoMode; > procedure Reset; > function IsSignaled return Boolean; > private > EventObject : CoreEvent_Ptr := null; > ManualReset : Boolean := FALSE; > end BaseEvent; > > But why is this necessary? Because, I think, CoreEvent is not completely defined at the point where you use it inside BaseEvent. Therefore the compiler does not know how much memory to allocate for a BaseEvent. By contrast, the access type is completely defined, so you can use it in the BaseEvent. > And can I create inheritable protected classes? No. This has been proposed as an extension to the language [1] back in 2000, but the discussions concluded that there was no demand for this feature from paying customers, so therefore no compiler vendors were going to implement it. [1] http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00250.TXT?rev=HEAD -- Ludovic Brenta.