comp.lang.ada
 help / color / mirror / Atom feed
* Implement Inheritance (Ada83)?
@ 1995-03-03 13:51 Dwayne Barrington
  1995-03-06 15:07 ` Kevin Weise
  0 siblings, 1 reply; 10+ messages in thread
From: Dwayne Barrington @ 1995-03-03 13:51 UTC (permalink / raw)


How do you implement inheritance using Ada83? Also, can you point me to any 
reference material? 

Thanks,
Dewayne Barrington
Harris Corporation



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

* Re: Implement Inheritance (Ada83)?
  1995-03-03 13:51 Implement Inheritance (Ada83)? Dwayne Barrington
@ 1995-03-06 15:07 ` Kevin Weise
  1995-03-07 12:19   ` Robert Dewar
  1995-03-07 13:19   ` Theodore E. Dennison
  0 siblings, 2 replies; 10+ messages in thread
From: Kevin Weise @ 1995-03-06 15:07 UTC (permalink / raw)


In article <3j76tl$nu4@jabba.ess.harris.com>,
Dwayne Barrington <dbarring@dw3f.ess.harris.com> wrote:
>How do you implement inheritance using Ada83? Also, can you point me to any 
>reference material? 
>
>Thanks,
>Dewayne Barrington
>Harris Corporation
Most people will tell you that this can't be done.  However, I seem to
remember an article in Ada Letters, circa 1989.  Don't exactly remember
the title; but I think it had to do with "Generics Revisited -
Implementing Inheritance in Ada '83."  Perhaps the author can respond to
this, too; I believe he has a variety of papers available from his home
page.  (Henry Baker, is this you?).

--------------------------------------------------------------------
Kevin J. Weise			weisek@source.asset.com
COLSA Corporation		Voice - (205) 922-1512 ext. 2115
6726 Odyssey Drive		FAX   - (205) 971-0002
Huntsville, AL  35806
{Standard Disclaimers about my opinions & my employer's opinions}
{... which are in conflict often enough}
----------------------------------------------------------------
"Admire those who seek the truth;
  avoid those who find it."		Marcel Proust



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

* Re: Implement Inheritance (Ada83)?
  1995-03-06 15:07 ` Kevin Weise
@ 1995-03-07 12:19   ` Robert Dewar
  1995-03-07 13:19   ` Theodore E. Dennison
  1 sibling, 0 replies; 10+ messages in thread
From: Robert Dewar @ 1995-03-07 12:19 UTC (permalink / raw)


Kevin Wise says, in response to the subject line

"Most people will tell you that this can't be done"

Count me out of most people! Inheritance is a conceptual idea, not a
syntactic gizmo. Yes, of course it is valuable to have syntactic sugar
to represent important concepts, but you can perfectly well implement'
the fundamental abstraction mechanism that we call inheritance in ANY
language!




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

* Re: Implement Inheritance (Ada83)?
  1995-03-06 15:07 ` Kevin Weise
  1995-03-07 12:19   ` Robert Dewar
@ 1995-03-07 13:19   ` Theodore E. Dennison
  1 sibling, 0 replies; 10+ messages in thread
From: Theodore E. Dennison @ 1995-03-07 13:19 UTC (permalink / raw)


Kevin Weise <weisek@source.asset.com> wrote:
> In article <3j76tl$nu4@jabba.ess.harris.com>,
> Dwayne Barrington <dbarring@dw3f.ess.harris.com> wrote:
> >How do you implement inheritance using Ada83? Also, can you point me to any
> >reference material?
> 
> Most people will tell you that this can't be done.  However, I seem to
> remember an article in Ada Letters, circa 1989.  Don't exactly remember
> the title; but I think it had to do with "Generics Revisited -
> Implementing Inheritance in Ada '83."  Perhaps the author can respond to
> this, too; I believe he has a variety of papers available from his home
> page.  (Henry Baker, is this you?).


There is also a rather good article on this subject in one of the 1989 issues
of ACM's SIGPLAN. If I remember correctly the conclusion was that you can do
full object-oriented programming in Ada (83), in a roundabout way. I'm sorry,
but I don't remember which exact issue it was (or who the author was).

Since this has been asked twice in the last month, perhaps it is a good
candidate for the FAQ?





T.E.D.




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

* Re: Implement Inheritance (Ada83)?
@ 1995-03-07 19:03 Jeff Seigle
  1995-03-08 13:28 ` Theodore E. Dennison
  1995-03-08 21:38 ` William Brennan
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Seigle @ 1995-03-07 19:03 UTC (permalink / raw)


In article <3jhj04$2dv@gnat.cs.nyu.edu> dewar@cs.nyu.edu (Robert Dewar) writes:
>....Inheritance is a conceptual idea, not a
>syntactic gizmo. ...you can perfectly well implement'
>the fundamental abstraction mechanism that we call inheritance in ANY
>language!

Although this statement is true, the best results are had when the language
has exlicit in its fabric the concepts that you are using to design your
software.  This seems to be the motivation for design of modern languages,
the support for techniques that developed as design concepts.
Years ago I wrote Fortran programs that used a quirk of the 
language to implement encapsulation (a kind of crude OOD; I won't include
the boring details here).  This approach has pros and cons.  The advantage
is that you are using concepts as advanced as you can without being 
constrained by the language.  The big negative is that once the code is 
written there is no enforcement of your wonderful ideas, and the next
one to come along with a mod can stomp down all of your imaginary fences.

Jeff Seigle
CSC




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

* Re: Implement Inheritance (Ada83)?
  1995-03-07 19:03 Jeff Seigle
@ 1995-03-08 13:28 ` Theodore E. Dennison
  1995-03-08 21:38 ` William Brennan
  1 sibling, 0 replies; 10+ messages in thread
From: Theodore E. Dennison @ 1995-03-08 13:28 UTC (permalink / raw)


Jeff Seigle <jseigle@csci.csc.com> writes:
> In article <3jhj04$2dv@gnat.cs.nyu.edu> dewar@cs.nyu.edu (Robert Dewar) writes:
> >....Inheritance is a conceptual idea, not a
> >syntactic gizmo. ...you can perfectly well implement'
> >the fundamental abstraction mechanism that we call inheritance in ANY
> >language!
> 
> Although this statement is true, the best results are had when the language
> has exlicit in its fabric the concepts that you are using to design your
..
> constrained by the language.  The big negative is that once the code is
> written there is no enforcement of your wonderful ideas, and the next
> one to come along with a mod can stomp down all of your imaginary fences.

True enough. But in Ada 83 the only thing that is really missing is dynamic
dispatching. The other major advantages to OO can be achieved with nested 
records and generics. 

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).

T.E.D.




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

* Re: Implement Inheritance (Ada83)?
  1995-03-07 19:03 Jeff Seigle
  1995-03-08 13:28 ` Theodore E. Dennison
@ 1995-03-08 21:38 ` William Brennan
  1995-03-10  9:35   ` Peter Hermann
  1 sibling, 1 reply; 10+ messages in thread
From: William Brennan @ 1995-03-08 21:38 UTC (permalink / raw)


In article <3jiala$kqs@explorer.csc.com>,
Jeff Seigle  <jseigle@csci.csc.com> wrote:
>[...]
>Years ago I wrote Fortran programs that used a quirk of the 
>language to implement encapsulation...
>The big negative is that once the code is 
>written there is no enforcement of your wonderful ideas, and the next
>one to come along with a mod can stomp down all of your imaginary fences.

And even having a design technique supported by the language is not enough.
Almost all of the packages I have written over the past 5 years use 
private types for data abstraction.  I have regularly seen occurences where
some maintainer would come by, figure he/she didn't have immediate
enough access to the type and move it into the visible part of the spec, 
breaking the encapsulation, of course.  One can hear them muttering under 
their breath: "What's this _private_ stuff for anyway, it's only getting in 
my way!"

Most of the people I work with seem to think that "encapsulation" is
a concept developed by academics for hypothetical programs.  If they know 
what it is at all.  Yikes!

-- 
----------------------------------------------------------------------------
                                                     === Team-Ada member ===
Bill Brennan                                  brennan@panther.warm.inmet.com



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

* Re: Implement Inheritance (Ada83)?
  1995-03-08 21:38 ` William Brennan
@ 1995-03-10  9:35   ` Peter Hermann
  1995-03-13  2:27     ` Mark A Biggar
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Hermann @ 1995-03-10  9:35 UTC (permalink / raw)


William Brennan (brennan@panther.warm.inmet.com) wrote:
: Almost all of the packages I have written over the past 5 years use 
: private types for data abstraction.  I have regularly seen occurences where
: some maintainer would come by, figure he/she didn't have immediate
: enough access to the type and move it into the visible part of the spec, 
: breaking the encapsulation, of course.  One can hear them muttering under 
: their breath: "What's this _private_ stuff for anyway, it's only getting in 
: my way!"

Most of the "need"s to do this will vanish with the 
appearance of child packages, imho.

--
Peter Hermann  Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)



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

* Re: Implement Inheritance (Ada83)?
@ 1995-03-10 15:15 Jeff Seigle
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Seigle @ 1995-03-10 15:15 UTC (permalink / 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.



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

* Re: Implement Inheritance (Ada83)?
  1995-03-10  9:35   ` Peter Hermann
@ 1995-03-13  2:27     ` Mark A Biggar
  0 siblings, 0 replies; 10+ messages in thread
From: Mark A Biggar @ 1995-03-13  2:27 UTC (permalink / raw)


In article <3jp6h3$p2t@info4.rus.uni-stuttgart.de> ucaa2385@iris2.csv.ica.uni-stuttgart.de (Peter Hermann) writes:
>William Brennan (brennan@panther.warm.inmet.com) wrote:
>: Almost all of the packages I have written over the past 5 years use 
>: private types for data abstraction.  I have regularly seen occurences where
>: some maintainer would come by, figure he/she didn't have immediate
>: enough access to the type and move it into the visible part of the spec, 
>: breaking the encapsulation, of course.  One can hear them muttering under 
>: their breath: "What's this _private_ stuff for anyway, it's only getting in 
>: my way!"
>Most of the "need"s to do this will vanish with the 
>appearance of child packages, imho.

Besides anyone that let such a code change pass a formal inspection should
be shot.  What?  Your not doing formal inspections?  Then your QA group should
be shot.

--
Mark Biggar
mab@wdl.loral.com






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

end of thread, other threads:[~1995-03-13  2:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-03-03 13:51 Implement Inheritance (Ada83)? Dwayne Barrington
1995-03-06 15:07 ` Kevin Weise
1995-03-07 12:19   ` Robert Dewar
1995-03-07 13:19   ` Theodore E. Dennison
  -- strict thread matches above, loose matches on Subject: below --
1995-03-07 19:03 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-10 15:15 Jeff Seigle

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