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@asp.camb.inmet.com (Mitch Gart) Subject: Re: Invoking parental methods (was: Java vs Ada 95) Date: 1996/11/06 Message-ID: #1/1 X-Deja-AN: 194862829 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: asp.camb.inmet.com references: organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-11-06T00:00:00+00:00 List-Id: Tucker is right. But here's a slightly different example, which shows the problem where a type conversion of an access type doesn't do what might be expected. The difference is that super is a classwide access type. with ada.text_io; use ada.text_io; 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; package body p1 is procedure p_first (param: access parent_obj) is begin put_line("parent p_first"); end; end p1; 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; child: aliased p2.child_obj; begin p2.p_first(child'access); end; The line marked *** dispatches back to p2.p_first, causing an infinite recursion. To get this one to do what's wanted, the notation p1.p_first(p1.parent_obj(param.all)'access); is needed. - Mitch