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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: Thomas.Kendelbacher@erno.de (Thomas Kendelbacher) Subject: Re: Ada95 OOP Questions Date: 1996/08/01 Message-ID: <4tpm7o$ld@mailsrv2.erno.de>#1/1 X-Deja-AN: 172689986 references: <4tor2u$ksg@Masala.CC.UH.EDU> organization: Daimler-Benz Aerospace, Space Infrastructure reply-to: Thomas.Kendelbacher@erno.de newsgroups: comp.lang.ada Date: 1996-08-01T00:00:00+00:00 List-Id: In article <4tor2u$ksg@Masala.CC.UH.EDU>, cosc19z5@Bayou.UH.EDU (Spasmo) writes: >Gotcha. So if I declare any type, tagged or not, then operations >will be inherited and I can refer to them in "child packages"? >This would mean that "inheritance" is pretty consistent regardless >of OO extensions or not eh? Right. >: There is an essential difference between objects in C++ and Ada, though; in Ada, >: you can't test for object identity as easily, like writing "this == that" in C++ >: (except if you explicitly switch to access types.) This can be a nuisance if >: you're used to OO languages which support object identity directly, like C++ or >: Smalltalk. > >Well the equality operations are defined for all types >so isn't it just a matter of saying if this = that >in Ada? No. The standard Ada "=" would just compare the contents of the records (if they are not limited), so two Persons with equal attributes would be considered the same person (that's equivalence, in contrast to object identity.) In C++/Smalltalk, you effectively compare pointers, so two Persons with the same name and birthday *won't* be merged into siamese twins... (Remember, in C++ "this" for a class X is declared implicitly as "X* const this" resp. "const X* const this", depending on the context.) Of course, you can have the same in Ada, if you use access types explicitly. In C++ (with the "this" pointer) you get this implicitly, and in Smalltalk every (non-numeric) object is unique by using object "handles" (references) uniformly for each and everything. (In fact, in Smalltalk you have two different operators, "=" testing for equivalence and "==" testing for object identity.) -- Thomas Kendelbacher | email : Thomas.Kendelbacher@erno.de DASA RI / Abt. RIT14 | voice : +49 421 539 5492 (working hours) Postfach 28 61 56 | or : +49 421 57 04 37 (any other time) D-28361 Bremen | fax : +49 421 539 4529 (any time) Germany