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

deadalnix deadalnix at gmail.com
Sun Sep 23 17:28:48 PDT 2012


Le 24/09/2012 02:21, Timon Gehr a écrit :
> On 09/24/2012 02:00 AM, deadalnix wrote:
>> Le 24/09/2012 01:28, Timon Gehr a écrit :
>>> I agree with Andrei. Single element tuples need to support the same
>>> operations as tuples of other arities do.
>>
>> Obviously it should. The whole point is that you can implicitly cast a 1
>> element tuple into the element and vice versa.
>>
>> like :
>> (int) a = (3); // a is a tuple of 1 element.
>> int b = a; // Implicit tuple unpack.
>> a = b; // Implicit tuple packing.
>
>
> Well, I do not want parentheses to randomly hide members.
>
> (a ~ b).length

Then it easy to add a comma to create a one element tuple. IE:

(a ~ b).length == a.length + b.length
(a ~ b,).length == 1


More information about the Digitalmars-d mailing list