Using <> for opCmp

Lionello Lunesu lio at lunesu.remove.com
Fri Nov 24 07:34:45 PST 2006


Anders F Björklund wrote:
> 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

The thing is, <> already exists! It's doing too much at the moment: it 
converts the int return value from opCmp to a boolean.

L.



More information about the Digitalmars-d mailing list