comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Dispatching problem.
Date: Fri, 07 Feb 2003 10:01:54 +0100
Date: 2003-02-07T10:01:54+01:00	[thread overview]
Message-ID: <kss64vcn2nohuvkt3q6jiduougefg7f7cg@4ax.com> (raw)
In-Reply-To: f74cb448.0302060604.e808c22@posting.google.com

On 6 Feb 2003 06:04:51 -0800, petter.fryklund.konsult@dynamics.saab.se
(Petter Fryklund) wrote:

>We have the following:
>
>package A is
>  type Msg;
>  type Msg_Ptr is access all Msg'Class;
>  type Msg is abstract tagged null record;
>  ... other declarations
>
>  type M1 is new Msg with ....
>  type M1_Ptr is access all M1;
>  type M2 is new Msg with ....
>  type M2_Ptr is access all M2;
>  ... other declarations
>
>  function X (Param : Integer) return Msg_Ptr;
>end A;
>
>with A;
>package B is 
>  type Msg is abstract new A.Msg with null record;
>  type Msg_Ptr is access all Msg;
>  type B1 is new A.M1 with null record;
>  type B1_Ptr is access all B1;
>  type B2 is new A.M1 with null record;
>  type B2_Ptr is access all B2;
>
>  procedure Y (MP : access B1);
>  procedure Y (MP : access B2); 
>end B;
>
>with A;
>with B;
>procedure Main is
>
>   X : A.Msg_Ptr;
>   Y : A.Msg_Ptr;
>begin
>   X := A.X (1);        -- Building a A.M1
>   Y := A.X (2);        -- Building a A.M2
>   B.Y (B.Msg_Ptr (X)); -- causes Constraint_Error Tag Check Failed to be raised. 
>end Main;
>
>How can we dispatch in package B?

You cannot dispatch "in a package". So what was the question?

If B.Y has to be dispatching, declare it appropriately. The first
question here is: what is the type class it dispatches over? From your
code follows that A.M1, A.M2 belong to the set. The single type class
which includes them and B.Msg is A.Msg. Thus Y has to be defined on
A.Msg:

package A.Msg is
   procedure Y (MP : access Msg) is abstract;

Note that it is abstract so you have to override it for A.M1, A.M2,
B.Msg etc.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  parent reply	other threads:[~2003-02-07  9:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-06 14:04 Dispatching problem Petter Fryklund
2003-02-06 15:33 ` James S. Rogers
2003-02-07  7:35   ` Petter Fryklund
2003-02-07  9:01 ` Dmitry A. Kazakov [this message]
2003-02-07 14:55   ` Petter Fryklund
2003-02-10  9:12     ` Dmitry A. Kazakov
2003-02-11  8:31       ` Petter Fryklund
  -- strict thread matches above, loose matches on Subject: below --
2008-01-15 18:55 petter_fryklund
2008-01-15 19:49 ` Dmitry A. Kazakov
2008-01-15 20:01   ` petter_fryklund
replies disabled

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