On Thu, 08 Dec 2011 12:17:20 -0000, so <[email protected]> wrote:

On Thu, 08 Dec 2011 11:17:48 +0200, Dejan Lekic <[email protected]> wrote:



Why is this operator still kept around?

No offense, but I find it strange/funny that you even ask why! :)

Have you never used comma in for loops???


Not sure if it is that relevant for D, but good point.

for(auto i=beg(), e=end(); i!=e; ++i)
for(auto i, j, k;; ++i, ++k)
...

It's kinda amusing that this thread appeared just as we had a case of this here at work. The developer accidentally coded something like...

if (function(..), FALSE)
{
}

Accidentally adding the ", FALSE" /after/ the ) instead of as a new parameter to the function.

(note; This was in C++ with default parameter values so the function can in fact take 1-4 args).

When I pointed this out, he said "how does that even compile" and was completely unaware of the existence of the comma operator, nor (once I explained it) did he realise it was in any way related to the comma used in for loops. People simply don't think of them as being the same thing at all. Instead, people learn the comma syntax as a special characteristic of the for loop, and use it nowhere else.

I think the comma operator is of little benefit (except where used in a for loop) and it is a source of bugs and we'd be better off without it. Even if it means porting C/C++ requires modification, or existing D (I doubt very much of it) breaks.

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to