May 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847



--- Comment #10 from Walter Bright <bugzilla@digitalmars.com> 2010-05-03 21:14:14 PDT ---
Just today on reddit I saw:

"I'm a bit embarrassed that after 10 years with C++ I learned something from a 12-bullet post intended for those new to the language. I'm amazed to learn that C++ has those built-in arithmetic keyword operators. I can't really see myself using them -- for various reasons -- but it's an interesting tidbit nonetheless."

http://www.reddit.com/r/programming/comments/bzcgn/c_for_c_programmers_part_12_the_nonoo_features/

It sums up the typical attitude I've seen towards them.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847



--- Comment #11 from bearophile_hugs@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: -------
September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847



--- Comment #12 from Stewart Gordon <smjg@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: -------
September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #13 from bearophile_hugs@eml.cc 2010-09-20 18:30:52 PDT ---
(In reply to comment #12)
Stewart Gordon:

> 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.

I understand this. On the other hand Python and Delphi use 'or' and 'and' (Python is partially derived from C). I know some Python programmers interested in D.


> D has continued this trend by doing away with the little-used and and or.

And D uses a semicolon where Java uses 'implements' and 'extends'.


> OK, so D has is and in, but these aren't things for which other C-like languages have symbols

In Python 'is' and 'in' have similar semantics.


> And maybe get confused when they find that they don't behave in the same way as in Perl and PHP.

Probably this is a confusion for D newbies only, while what I have suggested is meant to help life of normal D programmers.


> How's that a bug?  When a and b are bools, they behave the same!

OK. I close this enhancement request. If I will find other bug-prone situations I will reopen it. Thank you.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WONTFIX


--- Comment #14 from Brad Roberts <braddr@puremagic.com> 2010-09-20 18:37:57 PDT ---
It's not 'fixed'.  It's either 'invalid' or 'wontfix' or 'notabug'.  I'd prefer the latter, but since it's not available, going with 'wontfix'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3847



--- Comment #15 from BCS <shro8822@vandals.uidaho.edu> 2010-09-20 22:15:25 PDT ---
(In reply to comment #11)
> more
> readable and less bug-prone operators.

Franky I find the fact that && and || are not keywords make them *More* readable and as a result *Less* bug-prone. But there's no accounting for taste, yours or mine. One point to you, 1 point to me and Walter has trump.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »