<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure about how common it is, but I really don't like the idea of calls like swap(1, 2) being legal. Seems like a step backward from C++.<br>


</blockquote><br>There are useful analogs, however. E.g. consider<br><br><div style="margin-left:40px">heap.swap(parentIndex, parentIndex * 2 + 1)<br>heap.swap(getParent(index), index)<br><br></div>It's convenient and intuitive if the lvalues in these calls can be accepted by reference and modified. And it's not a problem that the modification to the rvalue is lost -- that's what's desired in this case.<br>

<br>One alternative which I haven't seen (though I haven't read the entire thread) is to require the caller to add some syntax when passing an rvalue to a ref parameter. E.g. in the above example<br><div style="margin-left:40px">

<br>heap.swap(parentIndex, tempRef(parentIndex * 2 + 1))<br><br></div>would look a little clearer, by making it more explicit what's going on with that second parameter. I imagine "tempRef" would have to be some language feature, a sort of alternative to "auto ref", but to be used at the call site.<br>

<br>Dmitry<br><br>