Using <> for opCmp

Lionello Lunesu lionello at lunesu.remove.com
Mon Nov 27 02:03:31 PST 2006


"Don Clugston" <dac at nospam.com.au> wrote in message 
news:eke9uq$2et5$1 at digitaldaemon.com...
> Lionello Lunesu wrote:
>> "Stewart Gordon" <smjg_1998 at yahoo.com> wrote in message 
>> news:ekcecj$iig$1 at digitaldaemon.com...
>>> Lionello Lunesu wrote:
>>> <snip>
>>>> The thing is, <> already exists! It's doing too much at the moment: it 
>>>> converts the int return value from opCmp to a boolean.
>>> Exactly.  And that's indeed what I'd expect it to do.  Why do you feel 
>>> that it's "too much"?
>>
>> The original opCmp return value is lost, so currently <> is exactly the 
>> same as != (except using opCmp instead of opEquals, I'd hope).
>
> Not quite.
> x != y
> is not the same as
> x <> y
> if x and y are reals (eg, x=2, y = real.nan:  x!=y is TRUE, but x <> y is 
> FALSE).
>
> I would expect that in the future there'd be an opUnorderedCmp(),
> which the NCEG operators would use (As well as floating point, the NCEG 
> operators could be used for tribools and SQL comparisions with NULL, for 
> example).

Right, for reals there's no simple "int opCmp", since there are more 
relations than the usual three, but even for reals <> could be made to 
return an int, where a value of 0 would not only mean a==b, but also 'either 
a or b is NaN' (correct?)

L. 





More information about the Digitalmars-d mailing list