Should the comma operator be removed in D2?

Leandro Lucarella llucax at gmail.com
Tue Nov 17 06:00:05 PST 2009


Yigal Chripun, el 17 de noviembre a las 07:06 me escribiste:
> Robert Jacques wrote:
> >On Mon, 16 Nov 2009 17:53:45 -0500, Stewart Gordon
> ><smjg_1998 at yahoo.com> wrote:
> >
> >>dsimcha wrote:
> >><snip>
> >>>Axe.  Looks like the only things it's good for are making code
> >>>undreadable and
> >>>abusing for loop syntax to...
> >>> Make code unreadable.
> >><snip>
> >>
> >>Suppose you want the increment of a for loop to change two
> >>variables in parallel.  I don't call that making code
> >>unreadable.
> >>
> >>Stewart.
> >
> >Yes the classic use case of the comma operator is multi-variable
> >declarations/increments in a for loop.
> 
> This was argued before and as I and others said before, this is
> *not* a use case for the comma separator.
> 
> e.g.
> for (int a = 0, b = 1; condition(); a++, b++) {...}
> 
> int a = 0, b = 1 // this is a declaration and not an expression
> 
> a++, b++ // isn't assigned to any variable and can be treated as a tuple

Exactly, all valid used of the comma operator can still be covered if the
comma becomes a tuple literal.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
A heart that's full up like a landfill,
a job that slowly kills you,
bruises that won't heal.



More information about the Digitalmars-d mailing list