RFC: moving forward with @nogc Phobos

Oren T via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 1 11:30:37 PDT 2014


On Wednesday, 1 October 2014 at 17:33:34 UTC, Andrei Alexandrescu 
wrote:
> On 10/1/14, 10:25 AM, 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).
>
> This all... looks arcane. I'm not sure how it can even made to 
> work if user code just uses "auto". -- Andrei

At the moment, @nogc code can't call any function returning a 
pointer. Under this scheme @nogc is allowed to call either code 
that returns an explicitly RC type (Exception, RCString) or code 
returning an "agnostic" unique pointer that may be used from 
either @gc or @nogc code.
I already see some holes and problems, but I wonder if something 
along these lines may be made to work.


More information about the Digitalmars-d mailing list