rvalue references

Tove tove at fransson.se
Tue Apr 23 01:41:15 PDT 2013


On Tuesday, 23 April 2013 at 07:18:41 UTC, Diggory wrote:
> I'd still like someone to explain how exactly "scope ref" would 
> differ from "ref" if DIP25/DIP35 were implemented.
>
> If the only difference is that "scope ref" can accept rvalues 
> then why would you ever use normal "ref"? There are no extra 
> restrictions needed on "scope ref" over and above normal "ref" 
> under the assumption of DIP25/DIP35.

DIP25 imposes a number of code-breaking restrictions even in 
@system code, if DIP36 was in place, one could consider imposing 
the DIP25 restrictions only in SafeD.

Furthermore if one day the compiler would be sufficiently smart 
to infer scope automatically, there still would be an important 
difference between 'ref' and 'scope ref'.

ref
rvalue ref would only work if the compiler succeeds in inferring 
scope, it could take a conservative approach to make sure it 
always err:s in the harmless direction... i.e. any '&' or any asm 
block is an automatic failure.

scope ref
Works unless the compiler can prove it wrong(also usable from 
SafeD if marked with @trusted).


More information about the Digitalmars-d mailing list