auto ref - again

Era Scarecrow rtcvb32 at yahoo.com
Sat Jan 26 18:28:21 PST 2013


On Sunday, 27 January 2013 at 01:23:18 UTC, Jonathan M Davis 
wrote:

> But it may not even end up being the case that using auto ref 
> on non-templated functions is the solution. It may end up being 
> something else entirely. Ignoring @safety issues, it seems to 
> me like it would be the most straightforward solution, but 
> there are @safety issues with ref in general that need to be 
> addressed, and Andrei intends to address them as part of 
> whatever happens with auto ref. That mean that auto ref gets 
> used for non- templated functions, or it could mean something 
> very different. I don't know what exactly the solution that 
> Andrei is working on could entail. For all I know, it'll 
> involve letting ref in general accept rvalues (much as I tihnk 
> that that's a horrible idea, it _has_ been suggested before). 
> So, without a clear idea of what we're going to want to do, 
> merging in the pull request which makes auto ref work for 
> non-templated functions is a bad idea. It could ultimately end 
> up being fine, or it could end up breaking more code when the 
> real solution gets implemented.

  Having ref accept rValues seems like a bad idea. If the source 
is const/immutable then it might be allowed, but more likely 
temporaries will be made for convertion from rValues to lValues, 
then passing off the temporaries. The temporaries to work right 
likely need to be at the top-most scope of whatever function you 
happen to be in; Beyond that I'm not sure how else the auto ref 
could be implemented safely.


More information about the Digitalmars-d mailing list