On 28 February 2015 at 01:43, Andrei Alexandrescu via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > On 2/27/15 7:17 AM, Manu via Digitalmars-d wrote: >> >> I'm not clear on structs. What is the order for calls; postblit, >> opInc, opDec, destructor? 75% of my use cases today are thin structs >> that wrap C/C++ api's. > > > Structs don't get any special treatment with DIP74, only classes and > interfaces.
Well this is the case of the highest value to me, and DIP74 offers nothing? Can I call opAddRef/opRelease from within the postblit/destructor manually and expect the compiler to elide calls correctly? That doesn't seem foolproof though, and you also said manual calls are not @safe. Why not specify a call sequence? >> There's no mention of 'scope'. I presume functions that receive scope >> RC arguments will have the opportunity to have opAddRef/opRelesae >> elided around the call? > > > That might be a future improvement. In fact that may be possible today; I've > spoken to an ARC expert who read DIP74 and said Apple's ARC does not insert > a retain() for a function call, i.e. it assumes functions only borrow unless > they actually do keep a pointer (e.g. assign to a member or global), and > only in that case inserts a retain(). > > If I'm not missing something, we can do this with DIP74 which will reduce > the opAddRef/opRelease traffic quite a bit. Hmmm, that does sound right. Very nice.