That title is odd i know but I just couldn't think of a short and easy way to sum it up. Basically, I remember reading on one of the forum threads that if you had for example: if(/*statement 1*/, /*statement 2*/); that statement 1 would always be true and would always be executed. Firstly, is this true? And if so, what are peoples views on using this?
This is an example of code that I have use this method with:
It's the purpose of the comma operator, it executes the left operand and returns the right one
It's quite a good feature. The problem is that some people read it as 'and' or something like that
It shouldn't be removed or deprecated
All right, the operator has its uses in the contexts listed.
I still vote for never. In my opinion, we should limit the number of calculations we do per inter-semicolon space. However, that comma in that context is basically just a way of fitting as many of those calculations as possible into a certain line. And when you have an if attached to that...
If the standards committee took away a C++ feature that at least one member of the forum was uncomfortable with /or afraid to use, there would be fu*kall left of the language.
Removing that operator would break this for (/*...*/;a++,b--) //... and this #define M(x) (x+=1, x*2) .
It's very easy to update a language when you don't have to deal with minutia, such as backwards compatibility. The problem is that you do have to, and removing operators is one of those things that break it.
Hey, since we're removing operators, why not merge assignment and equality into a single operator and add <> as inequality? Surely nothing can go wrong there!