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: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Ada95 OOP Questions Date: 1996/08/01 Message-ID: #1/1 X-Deja-AN: 171483261 sender: news@organon.com (news) references: <4tgi88$5fi@Masala.CC.UH.EDU> <4thu7u$ld3@mailsrv2.erno.de> organization: Organon Motives, Inc. 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? Basically, yes. But note that this is only true of _primitive_ operations. These can only be user defined if the type is declared in a _package spec._ and the operations are declared there along with it. If you declare the type anywhere else, the operations you provide (even if they are in the same immediate scope) are not primitive and will not be inherited: procedure P is type T is ... function F ( X : T ) return ... -- NOT primitive op of T type T2 is new T ... -- F is NOT inherited ... end P; package body B is type T is ... function F ( X : T ) return... -- NOT primitive op of T type T2 is new T ... -- F is NOT inherited ... end B; package C is type T is ... -- Defined in Pkg Spec. C function F ( X : T ) return... -- F IS primitive op of T type T2 is new T ... -- F IS inherited end C; package C.D is type T3 is new T2... -- F IS inherited ... end C.D; > : 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? Typically no. In general, this will provide value semantic _equality_ not _identity_, i.e., this and that have the same _value_ but are two different objects. /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com