comp.lang.ada
 help / color / mirror / Atom feed
* Dispatching problem.
@ 2003-02-06 14:04 Petter Fryklund
  2003-02-06 15:33 ` James S. Rogers
  2003-02-07  9:01 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 10+ messages in thread
From: Petter Fryklund @ 2003-02-06 14:04 UTC (permalink / raw)


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?



^ permalink raw reply	[flat|nested] 10+ messages in thread
* Dispatching problem.
@ 2008-01-15 18:55 petter_fryklund
  2008-01-15 19:49 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 10+ messages in thread
From: petter_fryklund @ 2008-01-15 18:55 UTC (permalink / raw)


Hi all!

I get compilation error when I  try to dispatch a call using class
wide access variables stating that I cannot call abstract program.

Perhaps oversimplified example is:

package PBN is
   type Item_T is abstract tagged null record;
   type Item_Ptr is access all Item_T'Class;
   function  Create (From : in String) return access Item_T'Class is
abstract;
   function  Img (From : access Item_T'Class) return String is
abstract;
end PBN;

package PBN.Site is
   type Site_T is new Item_T with
      record
         Name :  ASU.Unbounded_String;
      end record;
   type Site_Ptr is access all Site_T;

   function  Create (From : in String) return Site_Ptr;
   function  Img (From : access Site_T) return String;
end PBN.Site;

with Ada.Text_IO;
with PBN;
with PBN.Site;
procedure Print is
    Site :  PBN.Item_Ptr;
begin
    Site := PBN.Site.Create ("[Site qwerty]");
    Ada.Text_IO.Put_Line (Site.Img);             <-----------------
cannot call abstract program
end Print;

Any suggestions (apart from taking extensive course in OOD ;-) ?

Regards,
Petter



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-01-15 20:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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