Comma expressions must die [Was: Reddit: why aren't people using D?]

Jesse Phillips jessekphillips at gmail.com
Fri Jul 24 20:38:45 PDT 2009


On Fri, 24 Jul 2009 12:30:23 -0300, Leandro Lucarella wrote:

> Adam D. Ruppe, el 23 de julio a las 22:56 me escribiste:

>> Tuple!(int, int) getPoint() { return tuple(5,2); }
>> 
>> That works, but then you have to address the return value as:
>> 
>> auto p = getPoint();
>> p.field[0] == 5
>> p.field[1] == 2
>> 
>> 
>> Still, easy enough to say:
>> 
>> auto x = p.field[0]; auto y = p.field[1]; x == 5
>> y == 2
> 
> And you still think that's not remarkably worse than something like:
> 
> (int, int) getPoint() { return (5, 2); } auto (x, y) = getPoint();

I would say it isn't remarkably worse. The other one though, that was 
quite a mess.

> I really think that's the difference between happily using tuples or
> curse them for the rest of your life :)
> 
> I don't think comma expressions should be used for tuples (I don't care
> much either), but you can add support to the language without breaking
> them using something like @(1, 2, 3) or ![ 1, 2, 3 ] or whatever.
> 
> But you should support multple assignment, for example. If you don't,
> you don't have real tuple support, just a toy tuple emulation.

Tuples have nothing to do with multiple assignment, it is just something 
languages tend to provide.



More information about the Digitalmars-d mailing list