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,b5b9be54f5e38b13 X-Google-Attributes: gid103376,public From: jsa@organon.com (Jon S Anthony) Subject: Re: Implementation of "=" (Ada83) Date: 1996/07/15 Message-ID: #1/1 X-Deja-AN: 168366141 sender: news@organon.com (news) references: organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-07-15T00:00:00+00:00 List-Id: In article mheaney@ni.net (Matthew Heaney) writes: > There's one other implementation technique I thought of, that I don't > really like, but here it is: > package T_Package is > > ... > > private > > type T_Representation is > record > A, B : Integer; > end record; > > type T is new T_Representation; > > end; > > package body T_Package is > > function "=" (L, R : T) return Boolean is > begin > return T_Representation (L) = T_Representation (R); > end; > > end; This should work in both Ada83 and Ada95. Why don't you like it. Well, OK, maybe it isn't the most aesthetic thing, but this is kind of a "gotcha" in the language and you probably can't expect anything really clean... > Can anyone out there explain how they would implement the "=" for T? Probably as above. The trick is you have to separate the type definition from the implementation. Another hack would be: private type T_Rep is ... type T is record The_Impl : T_Rep; end record; ... return L.The_Impl = R.The_Impl; /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com