@nogc

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 13:28:36 PDT 2014


On Fri, Jul 11, 2014 at 08:10:21PM +0000, Chris Cain via Digitalmars-d wrote:
> On Friday, 11 July 2014 at 14:18:35 UTC, H. S. Teoh via Digitalmars-d wrote:
> >Wouldn't @reallynogc == @nogc + nothrow ?
> 
> Not precisely. Throwing is perfectly fine in @reallynogc. You just
> can't cheat by allowing allocating exceptions using the GC.
> Technically it *could* work, but removing exception handling is a bit
> of a drastic an excessive measure and would make the @reallynogc
> subset pretty weak, especially since basically no libraries are going
> to work at that point.

Good point. I retract what I said.

I think allowing GC operations when throwing Error's is OK, but allowing
Exceptions will open up all sorts of issues. It basically allows you to
cheat @nogc by throwing and catching exceptions within a library call,
which defeats the purpose of @nogc (why am I getting GC pauses mid-frame
when I explicitly said @nogc?! Wait, why this library call allocating
memory even though it's @nogc?! What do you mean it's throwing
exceptions under the hood?!).

I think allowing GC inside @nogc throw is bad. If you really mean
business about @nogc, you should be preallocating your exceptions and
avoiding 'new'.


T

-- 
Customer support: the art of getting your clients to pay for your own incompetence.


More information about the Digitalmars-d mailing list