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: mg@harp.camb.inmet.com (Mitch Gart) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/05 Message-ID: #1/1 X-Deja-AN: 194593362 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: harp.camb.inmet.com references: <1996Oct31.094136.1@eisner> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-11-05T00:00:00+00:00 List-Id: 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. - Mitch Gart