On 5/13/2014 6:36 AM, Dicebot wrote:
Main problem about making `ref` borrowed pointer is that you will need to
prohibit storing it in function transitively. This will need to become invalid
code:

struct A
{
     int* ptr;
}

int* gptr;

void foo(ref A a)
{
     gptr = a.ptr; // error, can't leak borrowed a.ptr into global context
}

The lifetime of &a is not at all the same as the lifetime of a.ptr, those are independent pointers. I.e. ref is not transitive (unlike const which is transitive).


Reply via email to