<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 January 2018 at 14:44, Timon Gehr via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:<br>
<br>
<a href="https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md" rel="noreferrer" target="_blank">https://github.com/tgehr/DIPs/<wbr>blob/tuple-syntax/DIPs/DIP1xxx<wbr>-tg.md</a><br>
<br>
<br>
This DIP aims to make code like the following valid D:<br>
<br>
---<br>
auto (a, b) = (1, 2);<br>
(int a, int b) = (1, 2);<br>
---<br>
<br>
---<br>
foreach((sum, diff); [(1, 2), (4, 3)].map!((a, b) => (a + b, a - b)))<br>
{<br>
    writeln(sum, " ", diff);<br>
}<br>
/+ prints:<br>
3 -1<br>
7 1<br>
+/<br>
---<br>
<br>
Before going ahead with it, I'd like some preliminary community input:<br>
<br>
- I'm not yet completely satisfied with the DIP.<br>
  (See section "Limitations".)<br>
  Please let me know suggestions or further concerns you might have.<br>
<br>
<br>
- There are good example use cases missing. While I'm confident I could<br>
  invent a few of them given a little time, I thought maybe I can<br>
  expedite the process and make the point more convincingly by asking<br>
  for use cases you encountered in your own code. The DIP already<br>
  contains an example due to bearophile.<br>
<br>
<br>
[1] <a href="https://forum.dlang.org/post/or625h$2hns$1@digitalmars.com" rel="noreferrer" target="_blank">https://forum.dlang.org/post/o<wbr>r625h$2hns$1@digitalmars.com</a><br>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">This is nice work!</div><div class="gmail_extra">I hope this is seriously considered.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'll add my 2c...</div><div class="gmail_extra">You discuss 'auto unpacking', can you justify the value of this?</div><div class="gmail_extra"><br></div><div class="gmail_extra">I quite like C++ explicit unpacking (using ...), and I wouldn't be upset to see that appear here too.</div><div class="gmail_extra">Explicit unpacking would solve your breaking change with auto unpacking, but the buggest advantage of C++'s '...' statement is that the unpack can involve expressions.</div><div class="gmail_extra">  auto t = (1, 2, 3);</div><div class="gmail_extra">  f(t...);          // <-- regular expansion: f(1, 2, 3);</div><div class="gmail_extra">  f(arr[t]...);    // <-- expression expansion: f(arr[1], arr[2], arr[3]);</div><div class="gmail_extra">etc...</div><div class="gmail_extra"><br></div><div class="gmail_extra">It's amazingly useful to perform tuple expansion on an expression involving the tuple!</div><div class="gmail_extra"><br></div><div class="gmail_extra">So, why might implicit expansion be preferred to explicit expansion?</div></div>