[Dlang-internal] DIP1000 discussion and testing

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Thu Oct 20 02:00:02 PDT 2016


On 10/19/2016 10:48 AM, Martin Nowak wrote:
 > Can we first get a high level overview about existing discussions and the 
goals/problems of DIP1000.

Simply put, it provides the means to guarantee that a pointer supplied as a 
function argument does not escape the scope of that function. Special 
consideration is given to functions that return their arguments.


> The DIP is named Scoped Pointers, but seems to address any escaping references
> (including classes).

It includes classes, delegates, and dynamic arrays.


> Will it fully enable @safe reference counted memory management?

No, because an RC design also requires the preincrement as noted below.


> What pieces of the puzzle are still missing?

The preincrement thing, but that is not DIP1000.


> How much of DIP1000 does #5972 implement?

All.


> I read that RC `opAssign` and `destroy` would remain unsafe b/c destroying the
> owner might leave a dangling ref parameter in `fun(ref RCS rc, ref int ri)`.
> It seems that unsafe assignment/destruction of RCs would be very limiting.
> Do we at least have an idea how to tackle this problem? In the RCClass idea an
> additional addRef/decRef call was proposed.
> Also see https://github.com/dlang/DIPs/pull/35#issuecomment-252345548.

The solution to that has been proposed and forgotten a couple of times. It is to 
have the compiler insert code to preemptively increment the reference count, 
then reassigning the RC object will not invalidate references to its internals. 
This is beyond the scope of DIP1000, though. DIP1000 is necessary for memory 
safety even without reference counting.



More information about the Dlang-internal mailing list