comp.lang.ada
 help / color / mirror / Atom feed
* I'm facing an issue with: call to abstract procedure must be dispatching
@ 2015-12-08 16:45 Serge Robyns
  2015-12-08 16:59 ` G.B.
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Serge Robyns @ 2015-12-08 16:45 UTC (permalink / raw)


Gents,

I've been trying to get my head around a way to create a solution where the storage method can be changed.  For this I'm using Ada's interface language construct.  So far I've only be successful with the following construct, whereas store1, store2, etc are implementations to store object1, object2, etc.  These are created as child packages of their respective objects so they can access the private parts.

   type T_Abstract_Data_Store is limited interface
     and Store1_Interface
     and Store2_Interface
     ...

In the implementation "class"

   type T_Data_Store is limited new T_Abstract_Data_Store with record
      Store1 : T_Store1;
      Store2 : T_Store2;
      ...

This then requires to write glue code to implement a link to the different implementations of the stores. 

procedure Insert (Store : in out T_Data_Store;
                  Obj   : in     T_XYZ'Class)
is
begin
    Store.Store1.Insert (Obj);
end Insert;

This could have been avoided if Ada would have allowed some form of multi-inheritance of in the instance of a multi-interface "class".

Now I've been trying to resolve this through another mean but I'm now facing the "call to abstract procedure must be dispatching" error message which I cannot explain nor resolve.

Below an a sample compile-able piece of code.

package Clients is
      -- could also be in private part ....
   type T_Client is tagged record
      ID : Natural;
   end record;
end Clients;

with Clients; use Clients;

package Abstract_Store is
   type T_Asbtract_Store is limited interface;

   procedure Insert (Store  : in out T_Asbtract_Store;
                     Client : in     T_Client'Class)
   is abstract;
   -- actually in my code Client will be a subclass of T_Client, for example
   -- T_Client_DAO'Class
end Abstract_Store;

with Clients; use Clients;
with Abstract_Store; use Abstract_Store;

procedure test is

   type T_Store is new T_Asbtract_Store with null record;
   
   overriding procedure Insert (Store  : in out T_Store;
                                Client : in     T_Client'Class) is
   begin
      null;
   end Insert;
   
   A_Store   : access T_Asbtract_Store;
   The_Store : aliased T_Store;
   Client    : T_Client;

begin
   A_Store := T_Asbtract_Store (The_Store)'Access;
   A_Store.Insert (Client);
end test;

The compiler does not like "A_Store.Insert (Client)".
Also with this construct I've to use an access variable ...

Anyone can shed a light on this or suggest a smarter Ada way?

Regards,
Serge

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

end of thread, other threads:[~2015-12-15  7:26 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 16:45 I'm facing an issue with: call to abstract procedure must be dispatching Serge Robyns
2015-12-08 16:59 ` G.B.
2015-12-08 17:04 ` Dmitry A. Kazakov
2015-12-08 17:24   ` Serge Robyns
2015-12-08 17:42     ` Dmitry A. Kazakov
2015-12-08 18:00       ` Serge Robyns
2015-12-08 18:22         ` Dmitry A. Kazakov
2015-12-08 20:21           ` Serge Robyns
2015-12-08 21:08             ` Dmitry A. Kazakov
2015-12-08 21:55               ` Serge Robyns
2015-12-08 22:43                 ` Serge Robyns
2015-12-08 22:55                   ` Jeffrey R. Carter
2015-12-09 23:03                     ` Randy Brukardt
2015-12-10  8:38                       ` Serge Robyns
2015-12-10 23:43                         ` Randy Brukardt
2015-12-09  8:48                 ` Dmitry A. Kazakov
2015-12-09 10:53               ` G.B.
2015-12-09 12:03                 ` Dmitry A. Kazakov
2015-12-09 13:42                   ` G.B.
2015-12-09 14:23                     ` Dmitry A. Kazakov
2015-12-08 22:55             ` Jeffrey R. Carter
2015-12-08 23:04               ` Serge Robyns
2015-12-08 23:42                 ` Jeffrey R. Carter
2015-12-09 13:40                 ` Jere
2015-12-09 13:48                   ` G.B.
2015-12-09 15:33                     ` Jere
2015-12-13 21:37                 ` Shark8
2015-12-14  2:20                   ` Jeffrey R. Carter
2015-12-15  7:26                     ` Shark8
2015-12-08 17:30 ` Jeffrey R. Carter
2015-12-08 17:48   ` Serge Robyns
2015-12-08 18:46     ` Jeffrey R. Carter
2015-12-08 20:28       ` Serge Robyns
2015-12-08 22:20     ` Simon Wright

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