DIP 36: Rvalue References

Dicebot m.strashun at gmail.com
Tue Apr 23 01:08:11 PDT 2013


On Monday, 22 April 2013 at 20:02:12 UTC, Andrei Alexandrescu 
wrote:
> In a way I wish my not being polite would be the main 
> bottleneck for this. I've been extremely busy at work, then 
> preparing for DConf 2013, and last week has been quite 
> distracting what with the Boston bombings three miles away from 
> where we live and all that. It strikes me as odd to be 
> obligated to spend time on something just because someone else 
> did, and framed as impolite if I don't.

Thanks for your time. Sometimes even simple "Have seen it, will 
answer later / after DConf is priceless".

> That being said, I have made a pass through this DIP and I have 
> the following concerns about it.
>
> 1. It defines a new language feature instead of improving the 
> existing ones. At this point in the development of the 
> language, our preference should be putting the existing 
> features in good order.

You consider "scope" a new language feature? And consider "auto 
ref" improvable solution. The very point of this DIP is to not 
create syntax-driven features, instead better define existing 
ones that make sense on their own so they can be used for same 
purpose.

> 2. The proposal is sketchy and does not give many details, such 
> as the lifetime of temporaries bound to scope ref objects.

It can't because lifetime of temporaries is not defined in D at 
all and suck stuff needs to be consistent. It is not really 
different from a lifetime of struct literal temporary used for 
pass-by-value.

> 3. The relationship with auto ref is insufficiently described, 
> e.g. there should be clarification on why auto ref cannot be 
> improved to fulfill the desired role.

auto ref is a template-world entity. If by "improved" you mean 
"completely reworked" than sure, I can add this rationale. Will 
do today.

> 4. Above all this is a new language feature and again we want 
> to resort to adding new feature only if it is clear that the 
> existing features are insufficient and cannot be made 
> sufficient. In particular we are much more inclined to impart 
> real, demonstrable safety to "ref" and to make "auto ref" work 
> as a reference that can bind to rvalues as well as lvalues.

Can't agree. "scope" is defined (but not implemented, a pity). 
Creating temporaries already exists for some cases. No really new 
language feature is added. No special syntax created. "scope ref" 
is still "scope" and "ref" with all semantics this imposes, 
rvalue references are just a side-effect. Contrary to this, "auto 
ref" IS a new feature created specifically for syntax hack. That 
is a very problem you are speaking about - introducing new 
concepts instead of making use of ones that exist for ages.


More information about the Digitalmars-d mailing list