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: jsa@alexandria (Jon S Anthony) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/08 Message-ID: #1/1 X-Deja-AN: 195344700 sender: news@organon.com (news) references: organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-11-08T00:00:00+00:00 List-Id: In article mg@asp.camb.inmet.com (Mitch Gart) writes: > procedure supertest is > package p1 is > type parent_obj is tagged null record; > type super is access all parent_obj'class; > procedure p_first (param: access parent_obj); > end p1; ...[snip]... > package p2 is > type child_obj is new p1.parent_obj with null record; > procedure p_first (param: access child_obj); > end p2; > package body p2 is > procedure p_first (param: access child_obj) is > begin > put_line("child p_first"); > p1.p_first(p1.super(param)); -- *** > end; > end p2; > The line marked *** dispatches back to p2.p_first, causing an > infinite recursion. To get this one to do what's wanted, the I'm not sure why anyone would think otherwise. I mean you haven't changed anything about the thing referenced. Would anyone be confused by: p : most_general_class_wide_access_type := new some_child_object q : most_general_class_wide_access_type := new some_other_child_object ... dispatchable_op(p); -- dispatch to some_child_object version dispatchable_op(q); -- dispatch to some_other_child_object version ?? If not, why would the above "super" example be confusing? Also, I think someone else pointed out a while ago that using subtypes (and maybe package renames) will make you immune to code "ripple effects" if you change the parent: with p ...; package parents renames p; subtype parent is parents.t; type x is new parent; ... Maybe news lost this... /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com