Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwvax!tank!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.sw.components Subject: Re: Inheritance vs. component efficienc Message-ID: <130200004@p.cs.uiuc.edu> Date: 15 Jun 89 15:21:00 GMT References: <5682@hubcap.clemson.edu> Lines: 23 Nf-ID: #R:hubcap.clemson.edu:5682:p.cs.uiuc.edu:130200004:000:1262 Nf-From: p.cs.uiuc.edu!johnson Jun 15 10:21:00 1989 From billwolf%hazel.c@hubcap.clemson.edu (Bill Wolfe) > Well, wouldn't you know it, a short little program can be written to take > an Ada package specification and automatically generate a corresponding > package body, with type definitions and the like recast as comments, and > procedures and functions rewritten as stubs. The same thing can be done > when you wish to add a layer of abstraction; simply have a program ask you > for the name of the new data type(s) and automatically generate a higher- > level package which implements itself through calls to the lower-level > packages. Q.E.D., as they say in mathematics... This is called delegation, which is a common way of implementing inheritance in object-oriented languages. One problem is that if you inherit procedure X, which calls procedure Y, but redefine Y then the inherited version of X will call the wrong version of Y. This can be solved by copying all the code in the original class, not just calling it. True delegation uses run-time polymophism to solve this problem, which is extremely useful for code reuse but is not present in Ada. However, it can be simulated with a preprocessor. I assume that is what the various versions of "object-oriented Ada" do. Ralph Johnson