comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic.brenta@insalien.org>
Subject: Re: Problem with protected type
Date: 25 Nov 2003 17:45:17 +0100
Date: 2003-11-25T17:45:17+01:00	[thread overview]
Message-ID: <m38ym4xuqq.fsf@insalien.org> (raw)
In-Reply-To: bpvtb2$a1o$1@online.de

"Ekkehard Morgenstern" <ekkehard.morgenstern@onlinehome.de> 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.



  parent reply	other threads:[~2003-11-25 16:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-25 15:15 Problem with protected type Ekkehard Morgenstern
2003-11-25 15:43 ` Ekkehard Morgenstern
2003-11-25 16:06   ` Robert I. Eachus
2003-11-25 18:39     ` Ekkehard Morgenstern
2003-11-26 15:43       ` Robert I. Eachus
2003-11-25 16:45   ` Ludovic Brenta [this message]
2003-11-25 18:45     ` Ekkehard Morgenstern
2003-11-25 20:09     ` Randy Brukardt
2003-11-25 18:03 ` Jeffrey Carter
2003-11-25 18:31   ` Ekkehard Morgenstern
2003-11-26  0:42     ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox