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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/08 Message-ID: #1/1 X-Deja-AN: 195381747 references: organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-11-08T00:00:00+00:00 List-Id: In article <55tm4r$8al@news.ida.org> wheeler@aphrodite (David Wheeler) writes: > I actually recommended such an attribute (I named it 'Parent) as > part of the Ada95 revision. My suggestion was struck down for the > reason you see here (you can emulate it with "subtype"). I still > think it's a good idea, even though there's a simple workaround, > because it simplifies maintenance and reduces possible errors > (e.g. forgetting to redefine subtype Parent when the hieararchy > changes). Once upon a time in Ada 9X you could emulate it fairly easily, if you knew the name of the parent. But with the current (and very correct) rules on dispatching, it can be VERY difficult to get the effect you want. (A view conversion to the parent type that dispatches dynamically or statically depending on context.) I argued for the attribute at more than one WG9 workshop, and got regularly put aside with "it is easy" to emulate. Now we have the rules for dispatching right but it can be very hard to get the dynamic behavior to work. I guess most people thought about the static case, and didn't realize that there are cases where you want the dynamic behavior. For example, suppose I want to find out how deep an inheritance is. I want to write: function Count_Depth(Bar: in Foo'CLASS) return Integer is begin if Foo'Tag = Bar'Tag then return 0; else return Count_Depth(Parent(Bar)) + 1; end if; end Count_Depth; This is a semi-silly example, but think about a typical window system where I want to add gadgets by inheritance. Most of the time, the behavior of the child statically calling the parent's method is fine, but often you want to walk the inheritance list, doing something at each level. You either define all these methods on the root class, which requires an impossible amount of forethough since you didn't write that package, or you make them classwide, and need the dynamic behavior. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...