From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b5b75c5bf3ae7291 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-10 07:52:07 PST Path: bga.com!news.sprintlink.net!uunet!in1.uu.net!explorer.csc.com!usenet From: Jeff Seigle Newsgroups: comp.lang.ada Subject: Re: Implement Inheritance (Ada83)? Date: 10 Mar 1995 15:15:00 GMT Organization: CSC Intelicom HQ, Bethesda MD Message-ID: <3jpqdk$pqd@explorer.csc.com> NNTP-Posting-Host: jseigle-pc.hq.csci.csc.com X-Newsreader: Date: 1995-03-10T15:15:00+00:00 List-Id: In article <3jkbep$d3f@theopolis.orl.mmc.com> "Theodore E. Dennison" 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.