D Language 2.0

Michel Fortin michel.fortin at michelf.com
Wed Jan 20 21:02:10 PST 2010


On 2010-01-20 23:43:58 -0500, BCS <none at anon.com> said:

> Why would having one chunk of code get checked for calls to the GC and 
> another not be any more complicated than mixing 
> malloc/free+add/removeRoot with normal GC? I'm beginning to wonder if 
> I'm calling for something different than other people are.
> 
> What I'm thinking of would have zero effect on the generated code, the 
> only effect it would have is to cause an error when some code would 
> normally attempt to invoke the GC.

Theoretically, I think you should be able to avoid GC calls in a 
function by using nothrow:

	void func() nothrow {
		auto a = new char[1]; // error: may throw
	}

Unfortunately, it doesn't seem to always work:

	void func(string a, string b) nothrow {
		auto c = a ~ b; // no error?
	}

But that's probably just a bug somewhere.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list