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,start X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Implementation of "=" (Ada83) Date: 1996/07/13 Message-ID: #1/1 X-Deja-AN: 168229482 organization: Estormza Software newsgroups: comp.lang.ada Date: 1996-07-13T00:00:00+00:00 List-Id: I have a question about how to implement the "=" for limited private types in Ada83. Suppose we have package T_Package is type T is limited private; function "=" (L, R : T) return Boolean; private type T is record A, B : Integer; end record; end; package body T_Package is function "=" (L, R : T) return Boolean is begin return ?; -- What goes here? end; end; I think the LRM says that an equality operator is "implicitly declared" at the point of declaration of the full view of the private type. Is this correct? If so, how do I refer to it? If I did this function "=" (L, R : T) return Boolean is begin return L = R; end; isn't this just recursive? Or do I just have to bite the bullet and do this function "=" (L, R : T) return Boolean is begin return L.A = R.A and L.B = R.B; end; Is this the expected implementation? 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; At least here, I can directly refer to the "=" for the record itself, and not to T's "=". Maybe this is what the Ada language designers intended in this case? Can anyone out there explain how they would implement the "=" for T? Thanks a bunch! matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant mheaney@ni.net (818) 985-1271