Optional braces

bearophile bearophileHUGS at lycos.com
Fri Aug 26 04:10:55 PDT 2011


Marco Leise:

> Is (!x & y) an issue or is it rather people omitting spaces in their code  
> !x&y ?

This topic was already discussed in past, in two threads, this one of them:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=135741

The Coccinelle tool has found a large number of  !x & y  bug patterns in already debugged high-quality C/C++ code. Search for "Correct occurrences of !x&y" in this page:
http://coccinelle.lip6.fr/impact_linux.php

See also, a good lint catches this bug:
http://d.puremagic.com/issues/show_bug.cgi?id=5814

It's a common mistake, it causes significant troubles, it's easy to catch, avoiding it is cheap syntax-wise, and there is a precedent similar case already implemented in D.


> If in the above case we are forced to write ((!x) & y) that's ... LISP.

Nope, it asks for just one pair of parentheses, like:
!(x & y)
Or:
(!x) & y


> least I'm not convinced by what is in the bug report.

You will have to bring on the table stronger evidence that this an useless change, if you want to refuse the enhancement request 5409. Walter and Don have accepted it, I think. I don't know what Andrei thinks of it.

Bye,
bearophile


More information about the Digitalmars-d mailing list