On 27.09.2010, at 20:54, Greg Ercolano wrote:
> Albrecht Schlosser wrote:
>> BTW, that's what the compiler warning was intended for.
>
>       Yes, I think the warnings did help us here, as getting precedence
>       wrong is apparently easy to do.
>
>       Quite honestly, I was surprised myself that '!=' took precedence over 
> '&'.
>       I would have thought it the other way around, had I not checked.

So would I, and I presume that the original author of these lines
thought so as well. The only reason I can think of why this precedence
order was chosen is because of boolean bitwise and / or in combination
with comparisons, such as:

   a = b != c & d == f ;

which would be with (hopefully correct ;-) parentheses:

   a = ( b != c ) & ( d == f ) ;

whereas we had a bit operation with a mask before comparison,
where we wanted the bit operation to take precedence:

   a = b & m != 0 ;

was intended to mean:

   a = ( b & m ) != 0 ;

but was with precedence rules:

   a = b & ( m != 0) ;

which is IMHO really surprising for a reader/programmer...

But it is as it is, and the compiler does what you tell it, and
not what you *intended* it to do ;-)

Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to