Mac Apps That Use Garbage Collection Must Move to ARC

Manu via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 03:12:13 PST 2015


On 23 February 2015 at 20:24, Jakob Ovrum via Digitalmars-d
<digitalmars-d at 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 at 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.


More information about the Digitalmars-d mailing list