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, WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5eb8ca5dcea2827 X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Ada OO Mechanism Date: 1999/05/27 Message-ID: #1/1 X-Deja-AN: 482876762 Sender: hymie@calumny.jyacc.com References: <7i05aq$rgl$1@news.orbitworld.net> <7i17gj$1u1k@news2.newsguy.com> <7icgkg$k4q$1@nnrp1.deja.com> <3749E9EC.2842436A@aasaa.ofe.org> <7id2eo$fag@drn.newsguy.com> <3749FF7D.F17CE16A@aasaa.ofe.org> <374AC676.F7AE0772@lmco.com> <7ieuja$5v9@news1.newsguy.com> <7ik1e5$8bc@news1.newsguy.com> X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 927842913 11635 209.49.126.226 (27 May 1999 22:08:33 GMT) Organization: PANIX Public Access Internet and UNIX, NYC NNTP-Posting-Date: 27 May 1999 22:08:33 GMT Newsgroups: comp.lang.ada Date: 1999-05-27T22:08:33+00:00 List-Id: Samuel Mize writes: > I hope you find this of some interest. I'm trying to wrap my head around this class-wide type stuff. I'm still at that stage of pre-clarity confusion :-) Here's some code I threw at gnat, based on Richard D. Riehle's example. -- in ft.ads package ft is m: boolean; type S is null record; a_f: S; type T is abstract tagged null record; function Get(F: S) return T is abstract; function GetC(F: S) return T'Class; type A is new T with null record; function Get(F: S) return A; a_a: A; type B is new T with null record; function Get(F: S) return B; a_b: B; end; -- in ft.adb package body ft is function GetC(F: S) return T'Class is begin if m then return a_a; else return a_b; end if; end; z: T'Class := GetC(a_f); function Get(F: S) return A is begin return a_a; end; function Get(F: S) return B is begin return a_b; end; begin z := Get(a_f); end; Gnat complains about the assignment to z: ft.adb:8:14: ambiguous expression (cannot resolve "Get") ft.adb:8:14: possible interpretation at ft.ads:12 ft.adb:8:14: possible interpretation at ft.ads:9 ft.adb:8:14: possible interpretation at ft.ads:6 >From reading the Rationale, I thought that the assignment to z would result in a dispatching call to Get, using the tag of z that was set at its initialization. What am I doing wrong here? How do controlling return types work?