comp.lang.ada
 help / color / mirror / Atom feed
From: "James A. Squire" <m193884@CSEHP3.MDC.COM>
Subject: Dispatching in Ada95
Date: 1996/04/18
Date: 1996-04-18T00:00:00+00:00	[thread overview]
Message-ID: <3176FEBF.5D3@csehp3.mdc.com> (raw)
In-Reply-To: md5:85373D6BBD0F0A69C09034C3F08892BC

I'm told that in object oriented programming like C++, one of the nice
aspects of the language is that dispatching occurs based on the object
instance that is being used - that in fact the method is prefixed by the
object instance and that is all it takes to find the code that needs to
be executed.

Look at the Ada95 Rationale, especially with respect to the
New_Alert_System example on page II-6 and the extension
Emergency_Alert_System on II-7, Class Wide programming is presented as
the way in which dispatching is implemented.

Unless I am totally dense, in order for dispatching to work in this
example as printed on page II-8, there is one vital element (which of
course is left out of the example on II-8):  "use New_Alert_System; use
Emergency_Alert_System;"

Otherwise, dispatching doesn't work, because once the 'Class attribute
is used to figure out the actual type of the Alert'Class parameter in a
given instance, and then the Ada83 rules kick in:  check all overloaded
subprograms _which are directly visible_ at that point in time and pick
the only one that matches the parameter profile.  Without the use
clauses, I presume something nasty like Program_Error would be raised.

How do people handle this?  I'm curious, especially since type extension
is intended to be possible without having to recompile the original
package.  Do you corrupt your application by using the use clause?  Or
do you work around this problem some other way?

Or am I missing something?
--
James Squire
MDA Avionics Tools & Processes
ja_squire@csehp3.mdc.com
"one of these days I'm going to better myself by going to Knight school"
"You'll be a web knight instead of a web page!"




       reply	other threads:[~1996-04-18  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <md5:85373D6BBD0F0A69C09034C3F08892BC>
1996-04-18  0:00 ` James A. Squire [this message]
1996-04-19  0:00   ` Dispatching in Ada95 Robert A Duff
1996-04-19  0:00 ` Samuel Tardieu
     [not found] <md5:5BDD03FA023B9E2881F3A55BFDD6938A>
1996-04-23  0:00 ` James A. Squire
     [not found] <md5:331AE542B80F60CE2470F379EDBF578B>
1996-04-22  0:00 ` James A. Squire
1996-04-23  0:00   ` Tucker Taft
1996-04-24  0:00   ` Robert Dewar
1996-04-24  0:00 ` Jon S Anthony
     [not found] <md5:F8080176D9F8A3EEEF6212652DAEEEE5>
1996-04-29  0:00 ` James A. Squire
1996-04-29  0:00   ` Robert Dewar
replies disabled

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