DIP19: Remove comma operator from D and provision better syntactic support for tuples

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Sep 25 06:38:04 PDT 2012


On 9/25/12 6:10 AM, deadalnix wrote:
> Le 24/09/2012 16:59, foobar a écrit :
>> I'm a bit confused about what is specifically proposed here:
>> - Is the suggestion to limit tuples to >1 elements? *This* I'm against
>> for practical as well as completeness reasons. Andrei already provided
>> one example, and another would be a proper unit type. e.g.
>> void foo(int a) {}
>> void bar (int b) { return foo(b); }
>> - Is the suggestion to allow implicit conversion between (T) and T?
>> This brings almost no benefit - (you save two keystrokes?) and adds a
>> special case to the language. The added complexity really does not
>> justify this.
>
> In fact, they don't need to unpack only for 1 element tuples, but this
> is the tricky case. Today, tuples auto unpack on function call for
> instance :
>
> auto t = tuple (1, 2);
> foo(t); // call foo(int, int)

Actually that's not the case. You need to write

foo(t.expand);

(and I think that's a good thing).


Andrei


More information about the Digitalmars-d mailing list