<div class="gmail_quote">On 13 March 2012 16:44, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">I thought more about it and we should be fine with two functions (untested):<br></div>
<br>
enum Skip {};<br>
@property ref Skip skip() {<br>
    static __gshared Skip result;<br>
    return result;<br>
}<br>
<br>
void scatter(T, U...)(auto ref T source, ref U targets) {<br>
    assert(source.length == targets.length);<br>
    foreach (i, ref target; targets) {<br>
        static if (is(typeof(target) != Skip)) {<br>
            target = source[i];<br>
        }<br>
    }<br>
}<br>
<br>
void gather(T, U...)(ref T target, auto ref U sources) {<br>
    assert(target.length == sources.length);<br>
    foreach (i, source; sources) {<br>
        static if (is(typeof(source) != Skip)) {<br>
            target[i] = source;<br>
        }<br>
    }<br>
}<br>
<br>
Usage:<br>
<br>
auto t = tuple(1, "hi", 2.3);<br>
int a;<br>
string b;<br>
double c;<br>
t.scatter(a, b, skip); // assigns a and b from tuple<br>
b = "!";<br>
++c;<br>
t.gather(skip, b, c); // assigns tuple from variables b and c</blockquote><div><br></div><div>Well, that 'works' :) .. Is that a proposal for a 'final' syntax, or something to work with in the mean time?</div>
<div>I said I've come to accept the Tuple <u>implementation</u>, but I'm absolutely not ready to accept the syntax baggage ;)</div><div>I'd really rather see something that actually looks like a language feature in its final manifestation. Is natural and convenient to read and type.</div>
<div><br></div><div>float t;</div><div>...</div><div>(myStruct.pos, t, _, int err) = intersectThings();</div><div><br></div><div>Or something to this effect. That's about as clear and concise as it gets for my money.</div>
</div>