Killing the comma operator
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 11 09:44:43 PDT 2016
On Wed, May 11, 2016 at 02:37:37PM +0000, burjui via Digitalmars-d wrote:
> 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).
That's what I've been saying, it should be treated as a special case in
the syntax of for-loops, but not as an operator in general.
T
--
A computer doesn't mind if its programs are put to purposes that don't match their names. -- D. Knuth
More information about the Digitalmars-d
mailing list