opCmp and opEquals woes
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 24 02:15:55 PDT 2014
On Thursday, 24 July 2014 at 06:46:08 UTC, Daniel Murphy wrote:
> "Ola Fosheim Grøstad" " wrote in message
> news:duuhouucozvosboibhtc at forum.dlang.org...
>
>> For fuzzy numbers you can define less than such that a<b and
>> b<a both are true... yes?
>
> You could, but if you do it with opCmp it looks like operator
> overloading abuse to me.
Well, but FuzzyNumbers are fuzzy sets that are treated like
scalars in a pragmatic, but imperfect way. It makes sense to
state that a vivid design A is both uglier and prettier than a
boring and dull design B.
I think opCmp is a mistake once you move beyond real scalars.
Defining sort order is a separate "tool". Take for instance
complex numbers that can be ordered by magnitude, but you need to
account for phase (in some arbitrary way since it is circular) to
get total order. That does not mean that one should use the
sort-comparison for non-sort comparison of complex numbers.
More information about the Digitalmars-d
mailing list