[Dlang-internal] DIP1000 discussion and testing

Martin Nowak via Dlang-internal dlang-internal at puremagic.com
Fri Oct 21 04:54:36 PDT 2016


On Friday, 21 October 2016 at 11:39:27 UTC, Martin Nowak wrote:
> The problem that remains could be stated as lifetime tunneling.
>
> Given `v2 = func(v1)` lifetime(v2) = lifetime(v1) according to 
> 5.
> Changing lifetime(v1) by `v1 = e` can change lifetime(v2) to < 
> reachability(v2).

This doesn't manifest easily because there are no named reference 
variables and converting references to pointers isn't allowed in 
@safe code.
But the void dangling(ref A a, scope ref B b) is one way to run 
into this.
Can we at least enforce that any value/reference returned by 
`func(v1)` cannot be bound to a v2 in the calling scope while 
still referencing v1?


More information about the Dlang-internal mailing list