A Fresh Look at Comparisons, Take 2

Yigal Chripun yigal100 at gmail.com
Sat Apr 19 14:14:01 PDT 2008


Janice Caron wrote:
> On 19/04/2008, Henning Hasemann <hhasemann at web.de> wrote:
>>> Yes, that's true. But remember, partially ordered types cannot be used
>>  > as AA keys (at least, not if the AA is implemented as a binary tree
>>  > with total ordering), so we've got a problem right there. How do we
>>  > tell AAs "Yes, we've implemented opCmp(), but you're not allowed to
>>  > use it because it's partial"?
>>
>> By using a syntax different to opCmp ;)
> 
> You mean, like I suggested earlier in this thread? ;)
> 
>    class P
>    {
>        bool partialLess(P p) {...}
>        bool partialGreater(P p) {...}
>    }


prepend those methods with "op" and the compiler would only generate the
 operators you specified under your partially ordered class. if you only
define opPartialLess than you can do (a < b) and (a > b) would be an error.
I'm not sure if that makes sense or not, but for partially ordered sets,
is it possible (mathematically speaking) to have only one of the
operators defined?

--Yigal



More information about the Digitalmars-d mailing list