comp.lang.ada
 help / color / mirror / Atom feed
From: ssmith@mprgate.mpr.ca (Shaun Smith)
Subject: Invoking Inherited Routines in Ada9x
Date: Thu, 5 Dec 91 09:16:23 PST	[thread overview]
Message-ID: <9112051716.AA04270@merengue.mpr.ca> (raw)

   I'm not a member of the mailing list, but since ``Dear Ada'' isn't
entertaining 9X questions as yet she/he recommended I mail to it to find
an answer to my question.

  In Ada9x, does you know how a subclass subprogram can invoke the
subprogram with the same name defined by an ancestor.  This is achieved
in Smalltalk by sending a message to "super".  By sending to "super"
rather than "self", the next implementation of a method in the
inheritance hierarchy is invoked rather than the one supplied by the
class of the current object.  Is that clear?

Here's the scenario in C++:

eg.     class A {
 	  virtual void foo(); // virtual means can be redefined by subclasses
 	}

	class B : public C {
 	  void foo(); // "virtualness" inherited
  	}

	class C : public B {
 	  void foo(); // "virtualness" inherited
  	}


	// In class C implementation file
	void C::foo() {
	   B::foo(); // must qualify the inherited member function with the
		     // name of the parent which defines it.
	}


C++'s solution to this requirment results in brittle code since one has to
specifically identify the parent class which supplies the next most
specific implementation of a member function (method).

Back to my question.  I've had a look through the Ada9x documentation
and can't find anything about how this will be done.   One person
familiar with Ada suggested that perhaps the package name could be used
to specify which class's implementatation of "foo" was desired.  This
suffers from C++`s problem.  In addition, isn't is possible to define an
arbitrary number of classes within a package.

If someone knows the answer, or which document and section to look in,
please let me know (by email since I'm not on the list).  I'm just
trying to get a handle on how Ada9x approaches support for
object-oriented programming.

       Shaun

Shaun M. Smith                  | ssmith@mprgate.mpr.ca
MPR Teltech Ltd.                | mprgate.mpr.ca!ssmith@uunet.uu.net
8999 Nelson Way, Burnaby, BC    | ssmith%mprgate.mpr.ca@relay.ubc.ca
Canada, V5A 4B5, (604) 293-5345 | 

             reply	other threads:[~1991-12-05 17:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-05 17:16 Shaun Smith [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-12-10 15:42 Invoking Inherited Routines in Ada9x Larry Maturo
1991-12-11 15:57 Alex Blakemore
replies disabled

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