draft proposal for ref counting in D

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


On 6/28/2013 6:42 PM, Michel Fortin wrote:
 > Le 28-juin-2013 à 17:03, Rainer Schuetze <r.sagitario at gmx.de> a écrit :
 >
 >> Any parameter of type C is also lowered to shared_ptr!C.
 > class C {}
 >
 > People still constantly forget that C used as a type represents a *reference* 
to an object of class C, not the object itself. If you replace type C with 
shared_ptr!C, you must then replace it with shared_ptr!(shared_ptr!C) and so on; 
there's no end to it.
 >
 > Also, I strongly doubt the compiler will be able to elide redundant calls to 
retain/release made within shared_ptr!C while still respecting normal struct 
semantics.
 >

Using some sort of shared_ptr!T was the original idea, but I could not figure a 
reasonable way to make it memory safe without the compiler knowing about it. The 
easiest way to have the compiler know about it is to make it some sort of class 
type, not a struct type.



More information about the Digitalmars-d mailing list