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,3ac1d8bc704e79f7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-07 01:01:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Dispatching problem. Date: Fri, 07 Feb 2003 10:01:54 +0100 Message-ID: References: NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1044608514 41625958 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:33873 Date: 2003-02-07T10:01:54+01:00 List-Id: 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