I was thinking about this again, and how the first 'ref' would create a copy in order to keep the object around. At first I thought I didn't like that, but then I realised that it's actually not far from what I wanted for taking r-values by reference. I commonly write functions which take values either by reference or by value in this way.

void foo(ref T value);
void foo(T value) { foo(value); }

Which obviously results in a combinatorial explosion of overloads, which you can write automatically some times with 'auto ref'.

My question is, in the greater context of the language, supposing we had this copying behaviour for a first ref for reference counted objects, will it putting something in the language for copying r-values into functions, or will it provide a path to implement such a thing?

Reply via email to