Killing the comma operator
burjui via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 11 07:37:37 PDT 2016
On Wednesday, 11 May 2016 at 13:29:56 UTC, Gopan wrote:
> int x;
> while( scanf("%d", &x), x!= 0) // until user input 0.
> {
> //do something with x
> }
>
> Does anybody think that this is a useful case of comma operator?
Well, it is, but judging from my experience, comma operator is
the most rarely used part of the language. I hardly ever needed
it in C and C++, where it originated, same with D and Java. In
fact, I had to check if it works in Java at all - turned out,
it's only allowed in "for" loops. Just never used it and forgot
about it.
The comma operator does more harm than good, is very rarely used
and is far less usable than tuples, so I'm all for killing it
(except in "for" loops).
More information about the Digitalmars-d
mailing list