The liabilities of binding rvalues to ref
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 9 19:05:43 PDT 2013
On Thu, 09 May 2013 21:47:14 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> On 5/9/13 4:36 PM, Peter Alexander wrote:
>> 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++.
>
> I think if we ever get swap(1, 2) to compile and run we'd effectively
> have destroyed the D programming language.
Depends on context.
int swap(int diskNum, int partitionNum);
Someone pointed out that swap could be a function that swaps heap indexes,
and might even take by ref not caring if you want the resulting value that
was swapped.
with(someHeap)
{
swap(1, 2); // swap indexes 1 and 2
}
-Steve
More information about the Digitalmars-d
mailing list