<div class="gmail_quote">On 9 March 2012 17:57, Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch">timon.gehr@gmx.ch</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">On 03/09/2012 04:38 PM, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 9 March 2012 16:27, Timon Gehr <<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a><br></div><div><div class="h5">
<mailto:<a href="mailto:timon.gehr@gmx.ch" target="_blank">timon.gehr@gmx.ch</a>>> wrote:<br>
<br>
    On 03/09/2012 01:23 AM, Manu wrote:<br>
<br>
        I can imagine syntax using parentheses, but I don't think I'm<br>
        qualified<br>
        to propose a robust syntax, I don't know enough about the finer<br>
        details<br>
        of the grammar.<br>
        Perhaps if other people agree with me, they could present some<br>
        creative<br>
        solutions to the syntax?<br>
<br>
        I imagine something like:<br>
        auto (x, y) = func(); // specify auto for all results?<br>
        float (x, y) = func(); // specify explicit type for all results?<br>
        (int x, float y) = func; // explicitly type each result?<br>
<br>
<br>
    This works, and Kenji Hara has already implemented appropriate<br>
    parser extensions.<br>
<br>
        int x; ... (x, float y) = func(); // assign to predeclared<br>
        variable(/s)?<br>
        (x, , z) = func(); // ignore the second result value<br>
        (elimination of the<br>
<br>
        second result's code path)<br>
<br>
<br>
    Those two would work, but (x,y) = func(); conflicts with the comma<br>
    operator. (I'd prefer (,) to be a tuple constructor though.)<br>
<br>
<br></div></div><div class="im">
You think so? Within that context, I would think the coma could be<br>
reinterpreted however it likes. The usual use of the coma operator makes<br>
no sense in this context?<br>
</div></blockquote>
<br>
void main(){<br>
    int a,b;<br>
    (a,b)=2;<br>
    assert(a==0);<br>
    assert(b==2);<div class="im"><br>
}<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
These last 2 examples are what I see as being the most important part,<br>
and the precise reason that it SHOULDN'T be a tuple.<br>
</blockquote>
<br></div>
You are probably confusing the tuple concept with a Phobos Tuple.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
The ability to<br>
directly assign results to explicit (existing) variables, and to ignore<br></div>
some/all of the return values, is a fundamental feature of the /concept/<div class="im"><br>
of return values universally.<br>
I see this as basically the whole point.<br>
Another example: (someStruct.x, y, , int err) = func();<br>
In this example, I assign the x result to a struct, y assigns to some<br>
existing local, we ignore z because we can (visually states our intent,<br>
would be hidden through use of a tuple), and we declare an int to<br>
capture a potential error in place.<br>
</div></blockquote>
<br>
This is simple pattern matching.</blockquote><div><br></div><div>I'm not sure what you mean by this?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If we were abusing the tuple syntax, we would need additional lines<br>
following the call to assign the rvalues out to their appropriate<br>
places, which is unnecessary spaghetti.<br>
</blockquote>
<br></div>
What you propose is tuple syntax.<br></blockquote><div><br></div><div>What I mean is this:</div><div><br></div><div>retTuple = func();</div><div>someStruct.x = retTuple[0];</div><div>y = retTuple[1];</div><div>// retTuple[2] is ignored, but the intent is not clear in the code as it was in my prior example, I like how my prior example makes this intent explicit</div>
<div>int err = retTuple[3];</div><div><br></div><div>This is pretty horrible. Surely you can see why I want to be able to arbitrarily assign the return values directly?<br></div><div>That's what I mean by 'abuse of the tuple syntax', but if that's not what you mean, then show me an example of the usage of your suggestion?</div>
</div>