Tuple DIP

Timon Gehr timon.gehr at gmx.ch
Wed Sep 19 21:48:40 UTC 2018


On 19.09.2018 23:14, 12345swordy wrote:
> On Tuesday, 3 July 2018 at 16:11:05 UTC, 12345swordy wrote:
>> On Thursday, 28 June 2018 at 13:24:11 UTC, Timon Gehr wrote:
>>> On 26.06.2018 11:55, Francesco Mecca wrote:
>>>> On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
>>>>> As promised [1], I have started setting up a DIP to improve tuple 
>>>>> ergonomics in D:
>>>>>
>>>>> [...]
>>>>
>>>> What is the status of the DIP? Is it ready to be proposed and dicussed?
>>>
>>> I still need to incorporate all the feedback from this thread. Also, 
>>> I have started an implementation, and ideally I'd like to have it 
>>> finished by the time the DIP is discussed. Unfortunately I am rather 
>>> busy with work at the moment.
>>
>> Is there any way we can help on this?
> 
> *Bump* I want this.

So do I, but I need to get a quiet weekend or so to finish this.

> I am very tempted to start my own dip on this and 
> finish it.

Here's the current state of my implementation in DMD:
https://github.com/dlang/dmd/compare/master...tgehr:tuple-syntax

It has no tests yet, but basically, with those changes, you can write 
tuple literals `(1, 2.0, "3")`, you can unpack tuples using `auto (a, b) 
= t;` or `(int a, string b) = t;`, and tuples can be expanded using 
alias this on function calls, so you can now write things like 
`zip([1,2,3],[4,5,6]).map!((a,b)=>a+b)`.

The implementation is still missing built-in syntax for tuple types, 
tuple assignments, and tuple unpacking within function argument lists 
and foreach loops.


More information about the Digitalmars-d mailing list