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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-23 19:03:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!chi1.webusenet.com!news.webusenet.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny03.gnilink.net.POSTED!53ab2750!not-for-mail From: "Stephane Richard" Newsgroups: comp.lang.ada References: <3F5F7FDC.30500@attbi.com> <3F6079A9.6080108@attbi.com> <3F60E380.4020307@attbi.com> <3F694186.5060709@crs4.it> <3F702545.6080704@crs4.it> Subject: Re: Is the Writing on the Wall for Ada? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Wed, 24 Sep 2003 02:03:08 GMT NNTP-Posting-Host: 129.44.78.151 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1064368988 129.44.78.151 (Tue, 23 Sep 2003 22:03:08 EDT) NNTP-Posting-Date: Tue, 23 Sep 2003 22:03:08 EDT Xref: archiver1.google.com comp.lang.ada:42835 Date: 2003-09-24T02:03:08+00:00 List-Id: "Matthew Heaney" wrote in message news:uu173vtv5.fsf@earthlink.net... > 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; > I have a question about this idiom. Taking your example here I'd like to have a classic example of the following using that idiom: I have Bird class that can fly, chirp, eat, hear and build a nest. I have a Horse class that can eat, run, walk, hear and sleep How, using your idiom, would I go about creating a Pegasus class ? >From reading your example it seems to me you're create an aggregation of TypeA and B from type C. Perhaps the example I state here might make it clearer on how the idiom works>? -- St�phane Richard "Ada World" Webmaster http://www.adaworld.com > > > > > > > > > > >