comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Problem with protected type
Date: Tue, 25 Nov 2003 11:06:28 -0500
Date: 2003-11-25T11:06:28-05:00	[thread overview]
Message-ID: <Kp6dnRXjpqyY416iRVn-sw@comcast.com> (raw)
In-Reply-To: <bpvtb2$a1o$1@online.de>

Ekkehard Morgenstern wrote:

> But why is this necessary?

It isn't in general.  What you are missing is a complete definition of 
CoreEvent before you try to create an object of the type:

  type CoreEvent is limited private;

  protected BaseEvent is
   entry Wait;
   procedure Signal;
   procedure ManualMode;
   procedure AutoMode;
   procedure Reset;
   function IsSignaled return Boolean;
  private
   EventObject : CoreEvent;  <----
   ManualReset : Boolean := FALSE;
  end BaseEvent;

Replacing EventObject by a pointer to CoreEvent eliminates the need for 
"knowing" the size of CoreEvent.  Other fixes would be to complete the 
declaration of CoreEvent before the declaration of BaseEvent, or to make 
  BaseEvent a protected type, then not create any objects of the type in 
the public part of the package specification.  (You may want to create 
such objects in child packages.)

I would think that the intent is to have several objects of type 
BaseEvent, so the latter would be the best fix.

This principle of linear elaboration order is followed thoughout Ada. 
There are cases where it is a pain, and other cases where it has 
benefits.  But there needs to be one rule for such things, and this rule 
was chosen as the simplest for users to understand.

Incidently, there is no language rule against the style of identifier 
you are using, but Ada compilers and editors do a better job of 
supporting Base_Event instead of BaseEvent.  For example the emacs 
ada-mode I use automatically converts BaseEvent to Baseevent unless I go 
to extra effort.
-- 
                                           Robert I. Eachus

100% Ada, no bugs--the only way to create software.




  reply	other threads:[~2003-11-25 16:06 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 [this message]
2003-11-25 18:39     ` Ekkehard Morgenstern
2003-11-26 15:43       ` Robert I. Eachus
2003-11-25 16:45   ` Ludovic Brenta
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