<div class="gmail_quote">On 16 March 2012 04:26, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<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">
A good design should strive to provide general features instead of<br>
special cases (E.g. swap is limited to the 2-tuple case). Also, why<br>
force an overhead of a function call on such a basic feature as<br>
assignment? Is swap usually inlined by the compiler?<br>
</blockquote>
<br></div>
Sorry, this is grasping at straws.<br>
<br>
1. swap can be easily generalized to take any number of arguments. I'm very happy that's possible, we've expended great efforts on making variadic functions as powerful as they are. But nobody asked for swap with many arguments until now. Which segues into...<br>

<br>
2. When was the last time you needed to swap arbitrary numbers of elements, and so badly and frequently, you needed a new language feature for that?<br></blockquote><div><br></div><div>This is called a swizzle. And constantly comes up when dealing with x,y,z,w, or r,g,b,a.</div>
<div>It could just as easily be expressed this way:</div><div>  a,b = tuple(b,a); // swap</div><div>  r,g,b,a = tuple(a,r,g,b); // swizzle</div><div>At which point this multi assignment boils down to the exact same question of syntax as MRV return assignment. I don't really distinguish this swap/swizzle from MRV. It all comes back to the return assignment syntax.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">3. Function overhead is solved by inlining, not by adding new features. That improves all functions, not only swap.</blockquote>
<div><br></div><div>Requiring inlining to make it efficient is not enough. The proposed MRV ABI would solve this not only for inlines, but for all multi-assignment type constructs, including distant function calls.</div></div>