On 23 February 2015 at 20:24, Jakob Ovrum via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > On Monday, 23 February 2015 at 01:38:35 UTC, Manu wrote: >> >> On 23 February 2015 at 07:47, Walter Bright via Digitalmars-d >> >> <digitalmars-d@puremagic.com> wrote: >>> >>> On 2/22/2015 8:36 AM, Manu via Digitalmars-d wrote: >>>> >>>> >>>> I have no idea where to start. >>> >>> >>> >>> Start by making a ref counted type and see what the pain points are. >> >> >> All my ref counting types fiddle with the ref in every assignment, or >> every function call and return. Unless the language has some sort of >> support for ref counting, I don't know how we can do anything about >> that. > > > There's no move constructor in D, so how did you manage that?
I wrote it above. struct Thing { T *instance; this(this) { Inc(instance); } ~this() { Dec(instance); } // this would really assist RC when 'scope' is inferred liberally. this(this) scope {} ~this() scope {} } In this case, rc is part of the instance; no reason to separate it when RC is not a generalised concept. Of course the structure can be generalised and fiddled/meta-ed to suit purpose in any number of ways. Inc's and Dec's galore! I'm not sure what a move constructor would give me over this.