<div class="gmail_quote">On 9 March 2012 16:27, 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 01:23 AM, 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">
I can imagine syntax using parentheses, but I don't think I'm qualified<br>
to propose a robust syntax, I don't know enough about the finer details<br>
of the grammar.<br>
Perhaps if other people agree with me, they could present some creative<br>
solutions to the syntax?<br>
<br></div><div class="im">
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>
</div></blockquote>
<br>
This works, and Kenji Hara has already implemented appropriate parser extensions.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
int x; ... (x, float y) = func(); // assign to predeclared variable(/s)?<br></div>
(x, , z) = func(); // ignore the second result value (elimination of the<div class="im"><br>
second result's code path)<br>
<br>
</div></blockquote>
<br>
Those two would work, but (x,y) = func(); conflicts with the comma operator. (I'd prefer (,) to be a tuple constructor though.)<br></blockquote><div><br></div><div>You think so? Within that context, I would think the coma could be reinterpreted however it likes. The usual use of the coma operator makes no sense in this context?</div>
<div><br></div><div>These last 2 examples are what I see as being the most important part, and the precise reason that it SHOULDN'T be a tuple. The ability to directly assign results to explicit (existing) variables, and to ignore some/all of the return values, is a fundamental feature of the <i>concept</i> of return values universally. I see this as basically the whole point.</div>
<div>Another example: (someStruct.x, y, , int err) = func();</div><div>In this example, I assign the x result to a struct, y assigns to some existing local, we ignore z because we can (visually states our intent, would be hidden through use of a tuple), and we declare an int to capture a potential error in place.</div>
<div>If we were abusing the tuple syntax, we would need additional lines following the call to assign the rvalues out to their appropriate places, which is unnecessary spaghetti.</div></div>