On 1/2/11 4:30 PM, spir wrote:
On Sun, 02 Jan 2011 20:56:48 +0000
Peter Alexander<[email protected]>  wrote:

This is great stuff, bearophile. Thanks for finding that. Please add
this as an enhancement request to bugzilla (disallowing (!x&y)
expressions).

That really surprises me that it's a common bug. Isn't it obvious that !
has higher precedence than&? Or have I totally misunderstood the cause
of the bug?

That's not such surprising: a study on the topic (operator priority) has shown 
a very high frequency of such errors (in C). The public were all highly 
educated, tranined, experienced, programmers.
On the other hand, the same study showed how ridiculous the proportion of lines 
of code holding poly-operator expressions is (which comparatively still highers 
the relative frequency of errors).
A logical conclusions is , I guess: is it worth complexifying a language (by a 
sub-language just for expressions, which is often the bigger and most complicated 
part of a parser)&  causing loads of bugs for a need that arises even 1000th 
lines of code?

I'd say that a class of bugs that occurs every 1000 lines, is traceable to a unique cause, is mechanically detectable with ease, and is easy to avoid by the programmer, is a MUST to eliminate through language design.

Phobos has 90K lines. If I could eliminate 90 bugs in it by a recompile, that would be awesome.

By the way - if (a & b == 0) is another one (Don worked on that).


Andrei

Reply via email to