Mac Apps That Use Garbage Collection Must Move to ARC

Manu via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 22 17:36:39 PST 2015


On 23 February 2015 at 06:49, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 2/22/2015 8:15 AM, Manu via Digitalmars-d wrote:
>>
>> I can't overload on 'scope'. How can I create a scope
>> constructor/destructor/postblit that doesn't perform the ref fiddling?
>
>
> I don't understand what you're trying to do.

struct RCThing
{
  RefType *instance;

  this(this) { IncRef(instance); }
  ~this() { DecRef(instance); }

  this(this) scope {} // <- scope instances don't need ref fiddling
  ~this() scope {}
}

Or various permutations along those lines.
Ie, library types may eliminate their ref fiddling when they are scope.


More information about the Digitalmars-d mailing list