struct X {
Y y;
ref Y getY() return { return y; }
}
This tells the compiler that getY() returns a referenced based on the implicit 'this' reference. It's available now (DIP25 was the proposal for it).We're now implementing DIP1000, which adds similar support for pointer values (DIP25 only dealt with references).
To see it in action:
alias Y = int;
struct X {
Y y;
ref Y getY() return { return y; }
}
ref Y foo()
{
X x;
return x.getY();
}
Compiling it yields: test.d(11): Error: escaping reference to local variable x