On Thursday, October 18, 2012 05:07:52 Malte Skarupke wrote: > My propsed solution is this: > - Make functions that take "ref in" arguments also accept rvalues.
There was some discussion of this, though that seems to me to be basically the same as making const ref take rvalues only worse. Certainly, it seems inherently broken to me to have a function try and take its arguement by ref and then be given an rvalue. > - The user can still provide an overload that accepts an rvalue, > using the "in" keyword, and that one will be preferred over the > "ref in" version. > > > What do you think? in as alias for const scope. scope is generally not applicable to structs (and when it is, it's not applied properly - scope currently only works properly for delegates), and const just puts us back at const ref again. You appear to be suggesting that in do something different here, and I don't think that that works. The most recent, in-depth discussion on this issue can be found here: http://forum.dlang.org/thread/[email protected] It wasn't entirely conclusive, but there _was_ some discussion on making ref take rvalues. I believe that more research was necessary, and I'm not sure where any of it stands now. One of the more promising ideas (IMHO) was to simply change it so that auto ref means what it was supposed to mean originally - that the programmer wants the argument to be passed efficiently but doesn't care whether it's an lvalue or rvalue - but some people screamed about that, because they've found the current version of auto ref to be useful (in spite of the fact that it doesn't do what it was supposed to do). Really, I think that this comes down to us needing to figure out how to make it so that ref can take lvalues under at least some set of circumstances (which seems like a bad idea to me), or we need to come up with a parameter attribute which indicates that we don't want the argument copied and don't care if it's an lvalue or rvalue (like const& is usually used for in C++ but making it so that it's _exactly_ that rather than just being primarily used for that). And if we can't use auto ref for that, then we need to come up with a new attribute of some kind to do that. However, IIRC Kenji tried to change auto ref to do that but ran into issues of some kind. I don't know where it stands now. - Jonathan M Davis
