DIP69 - Implement scope for escape proof references
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 9 10:28:58 PST 2014
On 09/12/2014 16:25, Steven Schveighoffer wrote:
> But I thought if you take a reference from the stack, it's inferred as
> scope? I feel like there's a missing link somewhere if the scope is
> missing from the parameter.
I think (with this DIP) values on the stack can safely be passed as a
ref parameter, which is a bit more flexible than a scope parameter.
> Will ref just automatically bind to any scoped reference?
>
> What about this:
(for reference:)
int x;
scope ref int foo(ref int x);
> auto y = &x;
>
> foo(*y) += 1;
y gets inferred as scope, but *y is not scope, so it should work.
More information about the Digitalmars-d
mailing list