comp.lang.ada
 help / color / mirror / Atom feed
* Dynamic dispatch and calling parent
@ 1996-10-23  0:00 Corey Minyard
  1996-10-23  0:00 ` Martin Lorentzon
  0 siblings, 1 reply; 2+ messages in thread
From: Corey Minyard @ 1996-10-23  0:00 UTC (permalink / raw)




I've looked through the FAQs, tutorials, and the rational and LRM and
I haven't found an answer to my question.  I am trying to create a
dynamically dispached function.  I want the function for the child
type to be able to call the parent's function much like you can in
Java, Oberon-2, C++, etc.  This way, the private parent portion may be
operated on.  However, I can't figure out how; my best guess is that
it is not possible.  Currently I am defining static and dynamically
dispached versions of the function and calling the static versions
from the child.  However, I consider this less than optimal.  I would
be disappointed if Ada couldn't do this.

Any help would be appreciated.  And this probably should be a FAQ
item.

Thanks,

Corey
-- 
Corey Minyard               Internet:  minyard@metronet.com
  Work: minyard@nortel.ca       UUCP:  minyard@wf-rch.cirr.com




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

* Re: Dynamic dispatch and calling parent
  1996-10-23  0:00 Dynamic dispatch and calling parent Corey Minyard
@ 1996-10-23  0:00 ` Martin Lorentzon
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Lorentzon @ 1996-10-23  0:00 UTC (permalink / raw)



>>>>> "Corey" == Corey Minyard <minyard@metronet.com> writes:

    Corey> I am trying to create a dynamically dispached function.  I
    Corey> want the function for the child type to be able to call the
    Corey> parent's function much like you can in Java, Oberon-2, C++,
    Corey> etc.

package root is

   type parent is tagged private;

   procedure foo(this : in parent);

private

   type parent is tagged null record;

end root;
------------------------------------------------------------
package root.child is

   type derived is new parent with private;

   procedure foo(this : in derived);

private

  type derived is new parent with null record;

end root.child;
------------------------------------------------------------
package body root.child is

  procedure foo(this : in derived)
  is
  begin

    -- Call the parent's operation by casting the type
    foo(root.parent(this));

    -- Do some operations on your own
    null;
  end foo;

end root.child;




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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-23  0:00 Dynamic dispatch and calling parent Corey Minyard
1996-10-23  0:00 ` Martin Lorentzon

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