D Language 2.0
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Jan 20 21:22:36 PST 2010
Michel Fortin wrote:
> 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.
I may be wrong about the current implementation, but allocation errors
aren't supposed to be sensed by nothrow.
Andrei
More information about the Digitalmars-d
mailing list