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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public From: John G. Volan Subject: Re: Real OO Date: 1996/03/30 Message-ID: <4jkgti$kb7@dayuc.dayton.saic.com>#1/1 X-Deja-AN: 145080167 distribution: world references: <65h8jGx-3RB@herold.franken.de> <4jf54u$o14@Sahara.enmu.edu> <4jh5cr$101s@watnews1.watson.ibm.com> content-type: text/plain; charset=ISO-8859-1 x-xxmessage-id: organization: Science Applications International Corp. (SAIC) mime-version: 1.0 newsgroups: comp.lang.ada,comp.object,comp.lang.eiffel Date: 1996-03-30T00:00:00+00:00 List-Id: In article <4jh5cr$101s@watnews1.watson.ibm.com> Norman H. Cohen, ncohen@watson.ibm.com writes: >No, the proper solution is to add the classwide function > > function Geometry_Of > (Graphic: Graphic_Type'Class) return Shape_Pointer_Type is > begin > return Graphic.Shape; > end Geometry_Of; > >(and possibly a Set_Geometry_Of procedure). Then, to test whether >Graphic_Type instances G1 and G2 have congruent polygons, we write > > Congruent (Geometry_Of(G1).all, Geometry_Of(G2).all) Actually, I think you might be able get by with: function Geometry_Of (Graphic: Graphic_Type'Class) return Shape_Type'Class is begin return Graphic.Shape.all; end Geometry_Of; I believe this would be a return-by-reference function, so I don't think there would be any extra copying involved. Of course, this only provides a "constant" view of the referenced Shape, so you couldn't then pass it into an "in out" parameter for instance. But you would be able to do: Congruent (Geometry_Of(G1), Geometry_Of(G2)) Note you could use the result of a call to Geometry_Of in this way even if Shape_Type happened to be limited (although you wouldn't be able to save the result in a variable, for instance). ------------------------------------------------------------------------ Internet.Usenet.Put_Signature ( Name => "John G. Volan", E_Mail => "John_Volan@dayton.saic.com", Favorite_Slogan => "Ada95: The *FIRST* International-Standard OOPL", Humorous_Disclaimer => "These opinions are undefined by SAIC, so" & "any use would be erroneous ... or is that a bounded error now?" ); ------------------------------------------------------------------------