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!postnews1.google.com!not-for-mail From: jonas.nygren@telia.com (jn) Newsgroups: comp.lang.ada Subject: Re: An improved Ada? Date: 29 Sep 2004 10:05:39 -0700 Organization: http://groups.google.com Message-ID: <311c6b78.0409290905.15ae255d@posting.google.com> References: <311c6b78.0409271138.1795d07c@posting.google.com> NNTP-Posting-Host: 217.210.29.242 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096477539 305 127.0.0.1 (29 Sep 2004 17:05:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Sep 2004 17:05:39 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4395 Date: 2004-09-29T10:05:39-07:00 List-Id: I got into a container discussion which was not the intention. I want improved OO capabilities in Ada. The way things are results in having to 'with' base class packages because not all methods seems to be inherited and also a lot of meaningless safe type conversions that should have been done by the compiler (my opinion) instead of the programmer. I have made a streamlined example to show my point - it gets complicated and difficult to understand even in these few lines of code, in large code bases it must be a nightmare. Are there really any codebases that applies 'tagged' types and type extension on a larger scale. Not just wrapping it up in generics. My small example plus detailed questions: 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 -- -- 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 end T;