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,c3a7c1845ec5caf9 X-Google-Attributes: gid103376,public From: clines@delete_this.airmail.net (Kevin Cline) Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/25 Message-ID: <33671d9c.5046069@news.airmail.net>#1/1 X-Deja-AN: 237201848 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> <335E0B1F.12C9@elca-matrix.ch> <335F5971.6375@elca-matrix.ch> Organization: INTERNET AMERICA Newsgroups: comp.lang.ada Date: 1997-04-25T00:00:00+00:00 List-Id: bobduff@world.std.com (Robert A Duff) wrote: > >The problem is that you don't know where it goes -- for example, suppose >there's a Sort generic. You don't know if it's defined in terms of "<=" >or ">=" -- and it doesn't matter, so long as nobody redefines one >without redefining the other. You should know. All comparison functions used by a generic should be generic formal parameters with defaults. The C++ standards committee wrestled with this one while defining the C++ Standard Template Library, (which provides a generic sort) and decided that all STL containers and functions would use only "<" and "=", an admirable decision in my opinion. It makes the implementation of the STL a teeny tiny bit harder, but eases the task for all users. >OK, but then if I redefine "<" on a scalar type, should ">=" change? >After all, ">=" is (or could be) defined as "not <". Only for totally-ordered sets. It is useful to redefine "<" and ">" to model partial orderings, in which case >= is not equivalent a < b. >Historical note: I believe the Red language tried to make sure >overloadings of the comparison ops "made sense" in this way -- you could >overload two of them, and the other four would automatically change. What a narrow view to take!