> > 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++. >
There are useful analogs, however. E.g. consider heap.swap(parentIndex, parentIndex * 2 + 1) heap.swap(getParent(index), index) 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. 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 heap.swap(parentIndex, tempRef(parentIndex * 2 + 1)) 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. Dmitry