Using <> for opCmp

Anders F Björklund afb at algonet.se
Fri Nov 24 07:00:21 PST 2006


Lionello Lunesu wrote:

> The operator < > <= >= all use opCmp, but if you want to differentiate 
> between the three cases (< == >) you either have to call opCmp yourself 
> or use multiple comparisons.
> 
> I'd like to suggest using the operator <> for an implicit call to opCmp, 
> returning the actual comparison value (<0, 0, >0).

I would prefer using <=> for this, as that is what Perl already does...
It is commonly used when writing sort functions, and called "starship".

Think it was suggested before, but the language wasn't taking in any
more operators at the time ? (The other one was ^^ for logical Xor.)

--anders



More information about the Digitalmars-d mailing list