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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,be02bcdb8f46ddd5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.wirehub.nl!easynet-monga!easynet.net!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada References: <311c6b78.0409271138.1795d07c@posting.google.com> <311c6b78.0409290905.15ae255d@posting.google.com> Subject: Re: An improved Ada? Date: Wed, 29 Sep 2004 14:26:30 -0400 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: <415afb9d$0$74192$39cecf19@news.twtelecom.net> Organization: Time-Warner Telecom NNTP-Posting-Date: 29 Sep 2004 18:14:53 GMT NNTP-Posting-Host: 935e99df.news.twtelecom.net X-Trace: DXC=MXYK_KcYbCDJAGY9:Pa>5EC_A=>8kQj6MMOj3YM9`=aH^[LckUePUJAdYZAA8S: "jn" wrote in message news:311c6b78.0409290905.15ae255d@posting.google.com... > > > package A is > type X is tagged private; > type Y is new X with private; > type Z is new X with private; > > type X_Ref is access all X'Class; > type Y_Ref is access all Y'Class; > type Z_Ref is access all Z'Class; > > function X_A (Xa : access X) return Y_Ref; > function Z_A (Zv : Z) return Y_Ref; > private > type X is tagged > record > Xr : X_Ref; > end record; > type Y is new X with null record; > type Z is new X with null record; > end A; > > package body A is > function X_A (Xa : access X) return Y_Ref is > begin return null; end; > function Z_A (Zv : Z) return Y_Ref is > begin return null; end; > end A; > > with A; > package B is > type Y is new A.Y with private; > type Y_Ref is access all Y'Class; > type Z is new A.Z with private; > > function Y_A ( > Ya : access Y ) > return Integer; > private > type Y is new A.Y with > record > Value : Integer; > end record; > type Z is new A.Z with null record; > end B; > > with A; > with B; > procedure T is > Z : B.Z; > Yr : B.Y_Ref; > begin > Yr := B.Y_Ref ( B.Z_A (Z) ); > Yr := B.Y_Ref (A.X_A (A.X_Ref (Yr))); > -- why not: > -- Yr := B.Z_A (Z); > -- B.Y is a descendant of A.Y that is a descendant of A.X > -- ret value 'tag' could be checked against Yr tag > -- why don't the compiler do it, why do I have to do it explicitly Well, obviously this is wrong. Operation B.Z_A returns type A.Y_Ref, not B.Y_Ref. > -- > -- why not: > -- Yr := B.X_A (Yr); > -- again, B.Y is a descendant of A.Y that is a descendant of A.X > -- why is not B.X_A visible, X_A should have been inherited > -- when A.X_A (Yr) is called, why is not the called dispatched? > -- I have to convert B.Y_Ref to A.X_Ref explicitly > -- and again I explicitly have to convert return type > -- from A.X_Ref to B.Y_Ref, a completely safe conversion Well, obviously this is wrong. There is no operation X_A that returns type B.Y_Ref declared in package B. You must be confusing this with the inherited operation X_A that returns type A.Y_Ref.