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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-23 18:47:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread1.news.atl.earthlink.net.POSTED!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: <3F5F7FDC.30500@attbi.com> <3F6079A9.6080108@attbi.com> <3F60E380.4020307@attbi.com> <3F694186.5060709@crs4.it> <3F702545.6080704@crs4.it> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 24 Sep 2003 01:47:39 GMT NNTP-Posting-Host: 65.110.133.134 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.atl.earthlink.net 1064368059 65.110.133.134 (Tue, 23 Sep 2003 18:47:39 PDT) NNTP-Posting-Date: Tue, 23 Sep 2003 18:47:39 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:42833 Date: 2003-09-24T01:47:39+00:00 List-Id: Jacob Sparre Andersen writes: > That was not really what I was worrying about either. I couldn't even > imagine that somebody would design a language that would allow a and b > to access each others variables. But that's more or less what the multiple views idiom let's you do in Ada95. For example given that we want to "inherit" from both of these types: type A_Type is tagged limited record X : Integer; end record; procedure A_Op (A : in out A_Type); type B_Type is tagged limited record Y : Integer; end record; procedure B_Op (B : in out B_Type); We can use our now-familiar idiom to let C_Type "inherit" from both A and B: type C_Type; type A_View (C : access C_Type) is new A_Type with null record; procedure A_Op (A : in out A_View); --override type B_View (C : access C_Type) is new B_Type with null record; procedure B_Op (B : in out B_View); --override type C_Type is tagged limited record A : aliased A_View (C_Type'Access); B : aliased B_View (C_Type'Access); Z : Integer; end record; procedure A_Op (A : in out A_View) is X : Integer renames A.X; Y : Integer renames A.C.B.Y; -- can see B's data Z : Integer renames A.C.Z; begin null; end; procedure B_Op (B : in out B_View) is X : Integer renames B.C.A.X; -- can see A's data Y : Integer renames B.Y; Z : Integer renames B.C.Z; begin null; end;