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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!unisoft!dual!ucbvax!ADA20.ISI.EDU!BBardin From: BBardin@ADA20.ISI.EDU Newsgroups: net.lang.ada Subject: Avoiding Recursion with Overloaded Operators Message-ID: <8609252230.AA03642@ucbvax.Berkeley.EDU> Date: Wed, 24-Sep-86 12:49:28 EDT Article-I.D.: ucbvax.8609252230.AA03642 Posted: Wed Sep 24 12:49:28 1986 Date-Received: Fri, 26-Sep-86 18:43:41 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet List-Id: In response to the question (from Pat Rogers at High Tech Lab) seeking a way to avoid a recursive call to an overloaded operator, consider: package P is type LP is limited private; function "=" (Left, Right : LP) return Boolean; private type T is access Integer; type LP is new T; end P; package body P is function "=" (Left, Right : LP) return Boolean is begin if T (Left) = T (Right) or else Left.all = Right.all then return True; else return False; end if; exception when Constraint_Error => return False; end "="; end P; -------- Other (less desirable) solutions include testing 'Left.all' and 'Right.all' individually to see if the both generate constraint errors, or (a little better) renaming the predefined operator before overloading it. The recommended solution was provided by Bryce Bardin, and has been tested on a validated compiler. Sincerely, John Prentice -------