rval->ref const(T), implicit conversions

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 18 11:32:19 PST 2016


On Monday, 18 January 2016 at 18:03:34 UTC, Namespace wrote:
> That is mine. I closed it after it was more or less abandoned.

Yeah.. I was initially for this proposal/PR, but on top of the 
fact that it will cause confusion because of how it differs from 
the template auto ref, it simply shouldn't be required at all.

The rationale for not allowing temporaries to be passed as ref 
params, IIRC, had two parts:
1) passing by ref should mean that the callee is meant to modify 
the parameter
2) the callee may escape the ref parameter which would be unsafe

I really don't feel the need to reiterate how broken the above 
logic is, as it's been stated so many times before, and I think 
it should really be as simple as this:

struct S;

void func(ref S s);
func(S());   // FINE

void func(ref S s) @safe;
func(S());   // ERROR


     Bit


More information about the Digitalmars-d mailing list