On Monday, 17 November 2014 at 20:07:54 UTC, Freddy wrote:
Why not make the compiler copy the variable how's address is
taken to the heap like how a closure does it? Would it be hard
that optimize away?
----
int* c;
int main(){
int a;
int* b=&a;//a is now a reference to the heap
c=&a;//safe
}
----
It would be safe, but it'd be another hard to detect source of GC allocations. Besides safety, an important purpose of borrowing is to avoid those.
