Xref: utzoo comp.object:662 comp.lang.c++:6015 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!think!snorkelwacker!bloom-beacon!eru!luth!sunic!tut!tukki!sakkinen From: sakkinen@tukki.jyu.fi (Markku Sakkinen) Newsgroups: comp.object,comp.lang.c++ Subject: Re: Dumb question Message-ID: <2625@tukki.jyu.fi> Date: 4 Jan 90 07:13:15 GMT References: <61737@aerospace.AERO.ORG> <2122@tukki.jyu.fi> <1990Jan2.112028.19312@xanadu.com> Reply-To: sakkinen@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) Organization: University of Jyvaskyla, Finland Lines: 39 In article <1990Jan2.112028.19312@xanadu.com> michael@xanadu.UUCP (Michael McClary) writes: >In article <2122@tukki.jyu.fi> sakkinen@jytko.jyu.fi (Markku Sakkinen) >SAKKINEN@FINJYU.bitnet (alternative) writes: >> >>Note 2: An old favourite idea of mine is that classes should offer, >>as a primitive operation, rather one comparison operator (values: >>equal, less, greater, incomparable, equivalent; possibly others >>in special cases) than several relational operators. The latter >>can be derived from the former, and class interfaces would be simpler. > >I recommend against this approach. Such an operator must fully >characterize the relationship between two objects to answer any >question about that relationship. Then the bulk of this work is >discarded. > ... No, I did not mean that the one operator should be able to fully characterise relatioships between objects in complicated cases. Rather, it should express some "canonical" order (or quasi-order) within the class. If there are several interesting order relations in a class, each of them should be represented by its own comparison-valued function. Of course, there are cases in which it is easier e.g. to test whether two objects are equal than to find out their exact relationship. I did not want to _prohibit_ the definition of conventional relational operators when deemed useful. For a more thorough treatment, see my article in ACM SIGPLAN Notices 22:8 (August 1987). The term 'quasi-order' is, however, used there incorrectly: I should have written 'weak order'; quasi-order is more general. Markku Sakkinen Department of Computer Science University of Jyvaskyla (a's with umlauts) Seminaarinkatu 15 SF-40100 Jyvaskyla (umlauts again) Finland