<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Regarding the syntax to unpack tuples into single variables, Kenji Hara wrote a DIP (<a href="http://wiki.dlang.org/DIP32" target="_blank">http://wiki.dlang.org/DIP32</a> ) denoting tuples with the univesal syntax {...}, but people have found some problems in it.</blockquote>
<div><br></div><div>Do you have a reference to the post(s) mentioning the problems with Kenji's proposed syntax?</div><div>Thanks</div><div><br></div><br><div class="gmail_quote">On Thu, May 30, 2013 at 5:29 AM, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com" target="_blank">bearophileHUGS@lycos.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Regarding the syntax to unpack tuples into single variables, Kenji Hara wrote a DIP (<a href="http://wiki.dlang.org/DIP32" target="_blank">http://wiki.dlang.org/DIP32</a> ) denoting tuples with the univesal syntax {...}, but people have found some problems in it.<br>

<br>
(I think Kenji didn't update that DIP with all the small improvements we suggested in that thread, so they risk getting lost.)<br>
<br>
Maybe one solution is to use a "tup(...)" syntax, it's a bit heavy, but it's clear and maybe it has no corner cases:<br>
<br>
tup(int, string) tup = tup(1, "hi");<br>
foreach (Float; tup(float, double, real)) { ... }<br>
auto tup(x, y) = tup(1, "hi");<br>
tup(auto x, y) = tup(1, "hi");<br>
tup(int x, string y) = tup(1, "hi");<br>
foreach (i, const tup(x, y); [tup(1,2), tup(3,4), tup(5,6), ...]) {<br>
void foo(tup(int, string name), string msg);<br>
(tup(A a, B b)) => a + b;<br>
switch (tup) { case tup(1, 2): ... }<br>
<br>
<br>
This is not very elegant, "tup" becomes a new keyword and generally I don't like such strong abbreviations, like the ones used in Rust language, but "tuple()" clashes with the library-defined ones, and it's even more wordy if you want to define an array of them:<br>

<br>
[tuple(1,2), tuple(3,4), tuple(5,6), ...]<br>
<br>
Bye,<br>
bearophile<br>
</blockquote></div><br>