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

deadalnix deadalnix at gmail.com
Tue Sep 25 07:05:30 PDT 2012


Le 25/09/2012 15:38, Andrei Alexandrescu a écrit :
> 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

OK, my bad. It means that tuple(...) behave differently than T... 
defined tuples.

And both behave differently than Caml or Haskell's tuples.

isn't the time for some unification ? Preferably on how tuples work in 
other languages, except if limitations can be shown and better proposal 
are made (and not include that in D2.xxx).


More information about the Digitalmars-d mailing list