RFC: moving forward with @nogc Phobos

Chris Williams via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 11:22:41 PDT 2014


On Monday, 29 September 2014 at 10:49:53 UTC, Andrei Alexandrescu 
wrote:
> On the caller side:
>
> auto p1 = setExtension("hello", ".txt"); // fine, use gc
> auto p2 = setExtension!gc("hello", ".txt"); // same
> auto p3 = setExtension!rc("hello", ".txt"); // fine, use rc
>
> So by default it's going to continue being business as usual, 
> but certain functions will allow passing in a (defaulted) 
> policy for memory management.

Forcing someone (or rather, a team of someones) to call into the 
library in a consistent fashion like this seems like a rather 
risky venture. I suppose that you could add some special compiler 
checks to make sure that people are being consistent, but I'd 
probably rather see some way of templating modules so that the 
chances for human error are reduced.

--- foo.d ---
module std.foo(GC = gc);

void bar() {
    static if (gc) {
       ...
    }
}

--- usercode.d ---
import std.foo!rc;

void fooCaller() {
     bar();
}

Though truthfully, I'd rather it be a compiler flag. But I 
presume that there's an issue with that, which it is too early 
for my brain to think of.


More information about the Digitalmars-d mailing list