http://d.puremagic.com/issues/show_bug.cgi?id=3847



--- Comment #11 from bearophile_h...@eml.cc 2010-09-20 17:24:18 PDT ---
(In reply to comment #10)
> It sums up the typical attitude I've seen towards them.


Some C++ programmers don't even know about 'and' and 'or' because the C++
compilers do nothing to suggest, encourage or force the usage of those more
readable and less bug-prone operators. The D compiler can avoid that trouble if
somehow && || become a legacy or deprecated (but probably supported still)
feature.

It's also a matter of idioms and customs: D is a new language, it's not just an
extension of the C language. So new D users usually accept the need to learn
new customs and new idioms specific of the D language. D does many things
differently from D (and even when it accepts C syntax, it's quite discouraged,
like using "int a[];"). If D style guides, standard library, newsgroups, and
books use 'and' and 'or' operators, new D programmers will use them.


Thanks to bug 4077, a problem is now mitigated, if the original program with
the thirdElementIsThree() function is compiled with dmd 2.049 plus warnings,
the compiler shows:

test.d(4): a.length >= 3 must be parenthesized when next to operator &
test.d(4): a[2] == 3 must be parenthesized when next to operator &


But fixing bug 4077 doesn't help bugs like:

void main() {
    bool a, b;
    if (a & b) {}
}


The usage of 'and' and 'or' operators avoids this class of bugs too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to