If !in is inconsistent because of bool/pointer, then so is !
Don
nospam at nospam.com
Fri Feb 6 22:23:00 PST 2009
Daniel Keep wrote:
>
> Rainer Deyke wrote:
>> Bill Baxter wrote:
>>> Note that D already has things like !>. But quoth the spec:
>>> "For floating point comparison operators, (a !op b) is *NOT* the same
>>> as !(a op b)."
>>> [emphasis added]
>> I had to check the spec for the difference. 'a !< b' and '!(a < b)'
>> /are/ equivalent in the sense that '(a !< b) == !(a < b)' for any values
>> of 'a' and 'b'. The vast majority of the time, the expressions 'a !< b'
>> and '!(a < b)' /are/ interchangeable. The difference is that '!(a < b)'
>> sets a global exception state if either operand is NaN, while 'a !< b'
>> does not.
>>
>> This is, in my opinion, a significant design error in the language. The
>> difference between '!(a < b)' and 'a !< b' is not obvious. There is
>> nothing about the operator '<' that suggests that it should set a global
>> exception state, and there is nothing about '!<' that suggests that it
>> should /not/ set a global exception state. (Is global state for error
>> reporting ever a good idea in a high-level language?) It also adds
>> awkward expressions to the language, not just in the form '!(a < b)',
>> but in the form '!(a !< b)'.
>
> I believe this is, or is the result of, an aspect of IEEE floating point.
>
> -- Daniel
Yes. It's the hardware. It's hard to find situations where the
difference matters. And this is why !<> and !<>= are the only ones of
those operators which are actually useful.
More information about the Digitalmars-d
mailing list