If !in is inconsistent because of bool/pointer, then so is !

Rainer Deyke rainerd at eldwood.com
Fri Feb 6 23:11:28 PST 2009


Daniel Keep wrote:
> Rainer Deyke wrote:
>> 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.

I don't have a copy of the IEEE floating point standard, but I strongly
suspect it would have allowed syntax like:
  a < b // sets global state
  a !< b // sets global state
  less_than_no_state(a, b) // does not set global state
  !less_than_no_state(a, b) // does not set global state
Or:
  a < b // does not set global state
  a !< b // does not set global state
  less_than_set_state(a, b) // sets global state
  !less_than_set_state(a, b) // sets global state
Or:
  a < b // sets global state
  a !< b // sets global state
  a [<] b // does not set global state
  a [!<] b // does not set global state
Or any number of other syntax choices, all less confusing than the
syntax actually used.

This is assuming we need two sets of comparison operators, one of which
uses global state to report NaN operands and one which does not.  I'm
not convinced that this is the case.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list