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,c3a7c1845ec5caf9 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/22 Message-ID: <335CB216.3197@elca-matrix.ch>#1/1 X-Deja-AN: 236666163 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> Organization: ELCA Matrix SA Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1997-04-22T00:00:00+00:00 List-Id: > In other words, how do I tell my "equal" function to be an equality > operator, authorized to be renamed into "="? HELP! :) There is a way, but it is contrived (Ada 83 was designed to make it impossible, but a hole was left. Use at your own risk as some compilers may not like it very much, and read the other replies about the reemergence of predefined "="): generic type T is limited private; with function "=" (X, Y : T) return BOOLEAN is <>; package MESS_UP_EQUALITY is package ENCLOSE_EQUALITY is function "=" (X, Y : T) return BOOLEAN renames MESS_UP_EQUALITY."="; end ENCLOSE_EQUALITY; end MESS_UP_EQUALITY; type T is ...; function Equal (L, R : T) return Boolean; package T_Equality is new MESS_UP_EQUALITY(T => T, "=" => Equal); function "=" (L, R : T) return Boolean renames T_Equality.Enclose_Equality."=";