[Issue 3847] To avoid a C code bug
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 20 18:07:48 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847
--- Comment #12 from Stewart Gordon <smjg at iname.com> 2010-09-20 18:04:33 PDT ---
(In reply to comment #11)
> 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.
But because && and || are by far the most commonly used forms, and
probably most modern languages with C-derived syntax are designed on
this very basis, deprecating them would probably confuse the
programmer by making D the odd one out.
Moreover, a trend that has distinguished C and its derivatives from
Pascal, Fortran, SQL et al is the tendency to make use of symbols,
thereby keeping down the number of keywords in the language. D has
continued this trend by doing away with the little-used and and or.
OK, so D has is and in, but these aren't things for which other
C-like languages have symbols (at least, I'm not sure if JS/PHP ===
is similar enough to count).
> If D style guides, standard library, newsgroups, and books use
> 'and' and 'or' operators, new D programmers will use them.
And maybe get confused when they find that they don't behave in the
same way as in Perl and PHP. Probably the obscurity of C's and/or
has meant that the designers of Perl and PHP saw nothing wrong with
changing the precedence. (Though why PHP's designer saw fit to
change the associativity of ?: is a mystery I haven't solved.)
> But fixing bug 4077 doesn't help bugs like:
>
> void main() {
> bool a, b;
> if (a & b) {}
> }
How's that a bug? When a and b are bools, they behave the same!
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list