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: jvl@ocsystems.com (Joel VanLaven) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/09 Message-ID: <1996Nov9.200813.14127@ocsystems.com>#1/1 X-Deja-AN: 195548634 references: <1996Oct31.094136.1@eisner> <1996Nov5.084722.1@eisner> organization: OC Systems, Inc. newsgroups: comp.lang.ada Date: 1996-11-09T00:00:00+00:00 List-Id: Larry Kilgallen (kilgallen@eisner.decus.org) wrote: : 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. I didn't see the original post, but from what I undeerstand of Ada95, this ought to behave as you seemed to originally intend. The way I understand it is if you don't use 'class anywhere (including in the declaration of super) then no dispatching takes place. If it is taking place then I would bet on a compiler bug. If you could provide a test case that demonstrates the problem you are having (preferably in e-mail as I missed the original post) I would love to test it out on our compiler. Remember, if you can make mistakes (especially interpreting RM rules) then compiler vendors sure can too. -- -- Joel VanLaven