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: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/05 Message-ID: <1996Nov5.084722.1@eisner>#1/1 X-Deja-AN: 194618532 x-nntp-posting-host: eisner.decus.org references: <1996Oct31.094136.1@eisner> x-nntp-posting-user: KILGALLEN x-trace: 847201648/18160 organization: LJK Software newsgroups: comp.lang.ada Date: 1996-11-05T00:00:00+00:00 List-Id: In article , mg@harp.camb.inmet.com (Mitch Gart) writes: > Larry Kilgallen (kilgallen@eisner.decus.org) wrote: > > : But the dangling reference seems to be precipitated by the > : the pointer object, not by the the pointer type. > : What is wrong with: > > : type super is access all parent_obj; -- this line may get changed > > : procedure p_first(param: access child_obj) is > : begin > : ... > : p_first(super(param)); -- call the parent's p_first > : ... > : end p_first; > > This is the trap I fell into the first time I tried to write this code. > The above solution doesn't work because the type conversion super(param) > converts param into a pointer to the parent type, but tag inside the > object that is pointed to still says the object is a child_obj, not a > parent_obj, so the call dispatches to the wrong place. This line > > : p_first(super(param)); -- call the parent's p_first > > in fact doesn't call the parent's p_first, in spite of the comment. If > the object pointed to by "param" is a child_obj this call is an infinite > resursion. Then I would judge this area of Ada 95 quite flawed. It is bad enough that ancillary changes must be made when genealogy is modified, but lacking a straightforward mechanism for knowing how many changes must be made to each package really takes the cake. Suggestions to survey all code for consequences when someone simply wants an "inherited" belong right up there with assertions that perfectly adequate code can be written in C if on pays strict attention to all details. Larry Kilgallen