"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 > > > > > > > > > > >