Question about auto ref

Namespace rswhite4 at googlemail.com
Mon Mar 25 12:43:29 PDT 2013


> Basically, someone needs to implement it and then talk Walter 
> into accepting
> it. That'll be easier for someone like Kenji, who's already a 
> major
> contributor, but in theory, anyone can do it. It's just that 
> there's a high
> risk that the pull request would languish for a while. And it 
> would probably
> need to be implemented with a name other than auto ref in order 
> to avoid the
> aforementioned problems, and having to agree on that could 
> cause further
> delay.

I am currently working in the required part of the compiler, but 
I need help and other opinions.
So far I've tried both: an implementation for auto ref and ref 
const.

  -> auto ref:
auto ref for non-template functions. In this case (as you had 
suggested it once) temporary variables are created for rvalues. 
Thus the behavior of auto ref would be different for template and 
non-template functions. But I do not see how that would be 
problematic.

  -> ref const:
const ref creates for rvalues a temporary variable that is then 
passed to the function. Advantage: It is like C++. Disadvantage: 
it could break code and you get always a const parameter.

As I said, I've tried both ways before. But I like to hear other 
opinions which of both would be more preferred.
And I would be glad about any kind of help (looking on my code 
etc.).
Maybe we could convince Walter and Andrei with a finished 
implementation.
I hope that no one like to have a new syntax for this kind of 
thing because then we will discuss another year...


More information about the Digitalmars-d-learn mailing list