RFC: moving forward with @nogc Phobos

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 1 23:29:24 PDT 2014


On 01/10/14 19:25, Oren T wrote:

> The idea is that the unique property is very short-lived: the caller
> immediately assigns it to a pointer of the appropriate policy: either RC
> or GC. This keeps the callee agnostic of the chosen policy and does not
> require templating multiple versions of the code. The allocator
> configured for the thread must match the generated code at the call site
> i.e. if the caller uses RC pointers the allocator must allocate space
> for the reference counter (at negative offset to keep compatibility).

Can't we do something like this, or it might be what you're proposing:

Foo foo () { return new Foo; }

@gc a = foo(); // a contains an instance of Foo allocated with the GC
@rc b = foo(); // b contains an instance of Foo allocated with the RC 
allocator

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list