RFC: moving forward with @nogc Phobos

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 30 08:32:05 PDT 2014


On 9/30/14, 7:05 AM, Foo wrote:
> On Tuesday, 30 September 2014 at 13:59:23 UTC, Andrei
> Alexandrescu wrote:
>> On 9/30/14, 6:38 AM, Foo wrote:
>>> I hate the fact that this will produce template bloat for each
>>> function/method.
>>> I'm also in favor of "let the user pick", but I would use a global
>>> variable:
>>>
>>> ----
>>> enum MemoryManagementPolicy { gc, rc, mrc }
>>> immutable
>>>     gc = ResourceManagementPolicy.gc,
>>>     rc = ResourceManagementPolicy.rc,
>>>     mrc = ResourceManagementPolicy.mrc;
>>>
>>> auto RMP = gc;
>>> ----
>>>
>>> and in my code:
>>>
>>> ----
>>> RMP = rc;
>>> string str = "foo"; // compiler knows -> ref counted
>>> // ...
>>> RMP = gc;
>>> string str2 = "bar"; // normal behaviour restored
>>> ----
>>
>> This won't work because the type of "string" is different for RC vs.
>> GC. -- Andrei
>
> But it would work for phobos functions without template bloat.

How is the fact there's less bloat relevant for code that doesn't work? 
I.e. it doesn't compile. It needs to return string for GC and RCString 
for RC.

Andrei



More information about the Digitalmars-d mailing list