comp.lang.ada
 help / color / mirror / Atom feed
* access types and dispatching subprograms
@ 1996-06-23  0:00 kbrun
  1996-06-23  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kbrun @ 1996-06-23  0:00 UTC (permalink / raw)



I have some trouble with Ada95 dispatching subprograms and access types.
AFAIK, a proc. call should dispatch if all corresponding actual parameters
are of (*or pointing to*) type T'Class and if the formal parameters are
of (*or pointing to*) type T. Still, the following code sample doesn't
work.

--

package T is

   type T is tagged null record;
   type T_p is access all T;
   type TC_p is access all T'class;

   type T1 is new T with null record;
   type T1_p is access all T1;

   procedure disp(p: T_p);
   procedure disp(p: T1_p);

   procedure do_dispatch;
end T;

package body T is

   procedure disp(p: T_p) is
   begin
     Put("T_p");
   end disp;

   procedure disp(p: T1_p) is
   begin
     Put("T1_p");
   end disp;

   procedure do_dispatch is
      classp: TC_p := new T1;
   begin
      disp(classp);	-- this call won't dispatch, instead it causes
                        -- a compiler error. what's wrong?
   end do_dispatch;
end x;

--

Could someone please enlighten me on this subject?

-- Klaus A. Brunner   Austria, Europe
-- mailto:kbrun@ibm.net





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

end of thread, other threads:[~1996-06-25  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-23  0:00 access types and dispatching subprograms kbrun
1996-06-23  0:00 ` Robert Dewar
1996-06-23  0:00 ` Robert A Duff
1996-06-25  0:00 ` Samuel Tardieu

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