draft proposal for ref counting in D

Walter Bright newshound2 at digitalmars.com
Wed Oct 9 19:21:19 PDT 2013


Rainer Schuetze wrote:

On 29.06.2013 00:22, Walter Bright wrote:
 >> Any parameter of type C is also lowered to shared_ptr!C.
 >
 > I don't see how lowering C to shared_ptr!C and lowering share_ptr!C to C
 > can work?

I don't see why you would want to lower from shared_ptr!C to C. It's only inside 
shared_ptr where access to the non-lowered C is needed, e.g. by disabling the 
lowering inside the shared_ptr. I was referring to "raw" references before, so 
the lowering would be better shared_ptr!(__raw(C)). But I agree, having the 
lowering include the original seems bad.

I realized a worse flaw with my proposal: it doesn't solve the assignment 
problem it was meant to. shared_ptr implemented as a struct does not have full 
control of the assignment, but is only called for the postblit and the 
destruction of the previous value. It has no way to put a lock around the full 
assignment. Still thinking too much C++...

Sorry for the noise.


More information about the Digitalmars-d mailing list