My thoughts & tries with rvalue references

Namespace rswhite4 at googlemail.com
Mon Apr 1 02:09:50 PDT 2013


> It's esoteric, which is bad, but concise, which is good. I 
> think perhaps the annoying aspect of this feature is how 
> attractive it would be to just get the power of the feature 
> implicitly without needing a new attribute or keyword.
Maybe you're right. But I like the idea that, if you want strict 
lvalues, you use 'ref' and if you don't care, you use the C++ 
style. I think that would be the best idea.

But currently I have a problem with the implemenation of 'A&'. I 
do not know how to convey the fact that behind the type is a '&'. 
IMO the correct D way is to create a new type like TypePointer -> 
TypeRvRef. But my attempts failed so far to create such type.
Because of that I decided to declare a boolean flag 'isRvRef' 
inside of the basic Type struct which I set to TRUE if a '&' is 
behind the type. This works and don't break any code but I think 
that should be fixed by someone with more knowledge.
But I think also that this rvalue problem has a very low priority.
So if we want to resolve this issue, then we need to do it 
yourself.
If someone wants to help me, the code and the current solution is 
on github:
https://github.com/Dgame/dmd/tree/rvalueRef

> To get it implicitly, and only have an attribute for when you 
> *don't want an rvalue, e.g.:
>
> void foo(@lvalue ref T a) {}
>
> ...would break code, but is nonetheless less something to 
> consider also.

Walter hate to break code, so the introduction of that would be 
even much less likely.

And yes you're right, when I said 'property' I meant an 
attribute. ;)


More information about the Digitalmars-d mailing list