<div class="gmail_quote">On 15 March 2012 17:32, 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">On 3/15/12 5:14 AM, Iain Buclaw 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 15 March 2012 09:52, Derek<<a href="mailto:ddparnell@bigpond.com" target="_blank">ddparnell@bigpond.com</a>>  wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Are you saying that the generated code is something like ...<div class="im"><br>
<br>
   struct __tmpS { int Fa, int Fb };<br>
   __tempS __tmp;<br>
   __tmp.Fa = a;<br>
   __tmp.Fb = b;<br>
   a = __tmp.Fb;<br>
   b = __tmp.Fa;<br>
<br>
</div></blockquote>
<br><div class="im">
In effect, yes.  Given that the call to from() is inlined. :-)<br>
<br>
In GDC, you have a -fdump-tree-original switch that dumps a debug<br>
representation (that just so happens to look C-like) of the AST of the<br>
code to a file.  You could use this to unravel some of the magic going<br>
on under the covers. ;-)<br>
</div></blockquote>
<br>
One note - the code is really ingenious, but I still prefer swap() in this case. It's more concise and does less work in the general case.<br>
<br>
swap(a[i + k], a[j + j]);<br>
<br>
only computes the indexing once (in source, too).</blockquote><div><br></div><div>It all still feels to me like a generally ugly hack around the original example:</div><div>  a,b = b,a;</div><div><br></div><div>What is the significant importance of the existing coma operator? What does it offer that couldn't possibly be achieved any other way?</div>
</div>