The purpose of D (GC rant, long)

BCS BCS at pathilink.com
Thu Oct 26 16:40:35 PDT 2006


How much does the runtime, generated code and Phobos depend on the GC?
Does it try to optimize out allocations or delete things it can?
For example, does this preform one allocation or several?

char[] foo = "abc", bar = "baz";
char[] ret = foo ~ bar ~ foo;

// ret.length = 9;
// ret[0..3] = foo;
// ret[3..6] = bar;
// ret[6..9] = foo;

and would these temporaries get deleted (or maybe not even created)?

if((foo ~ bar)[4]=='g') go();

//auto __tmp = foo ~ bar
//if(__tmp[4] == 'g') go();
//delete __tmp;

or

//if( (foo.length>4 && foo[4]=='g') || bar[4-foo.length]=='g') go();



More information about the Digitalmars-d mailing list