comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff Seigle <jseigle@csci.csc.com>
Subject: Re: Implement Inheritance (Ada83)?
Date: 10 Mar 1995 15:15:00 GMT
Date: 1995-03-10T15:15:00+00:00	[thread overview]
Message-ID: <3jpqdk$pqd@explorer.csc.com> (raw)

In article <3jkbep$d3f@theopolis.orl.mmc.com> "Theodore E. Dennison" <dennison@escmail.orl.mmc.com> writes:
>....
>Type extension can be achieved by making the "parent type" a record field in
>the
>child type. "Inheritance" is sort of automatic (just pass the parent field to
>its routines. Static dispatching can be achieved via overloading. Dynamic 
>dispatching ... SOL. Creation and deletion methods ... SOL (although there are
>things you can do to "force" creation).

It sounds like you are suggesting the following technique:  

Write a package with, say, a private type and operations on it.  Write 
another package with another private type.  The
second private type is implemented as a record, with one component of the
type defined in the first package.  The second package gives in its
specification a subprogram corresponding to each procedure available in the
first package.  The body of the subprograms in the second package are
implemented by simply calling the corresponding subprogram in the first
package.  If you use "use" clauses, you get what I think you referred to as
static dispatching.    This is definitely an implementation of the concept
of inheritance.  The *use* of these constructs is automatic, in that the 
caller can use the same (overloaded) subprogam name when invoking the
operations of either the parent or child type.  But the building of this
mechanism is very much manual.  And adding an operation to the parent
package means you have to somehow remember that you need to add it to the
child package.

Another kind of inheritance in Ada is if you derive a data type from a
private type, the derived type also inherits all of the 
subprograms you wrote for the base type.  This is true automatic
inheritance--you don't have to write those pass-throughs.   But it has 
limited utility; you can write additional operations
for the derived type but you can't give it additional attributes, as you 
can in the previous example.



             reply	other threads:[~1995-03-10 15:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-10 15:15 Jeff Seigle [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-03-07 19:03 Implement Inheritance (Ada83)? Jeff Seigle
1995-03-08 13:28 ` Theodore E. Dennison
1995-03-08 21:38 ` William Brennan
1995-03-10  9:35   ` Peter Hermann
1995-03-13  2:27     ` Mark A Biggar
1995-03-03 13:51 Dwayne Barrington
1995-03-06 15:07 ` Kevin Weise
1995-03-07 12:19   ` Robert Dewar
1995-03-07 13:19   ` Theodore E. Dennison
replies disabled

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