DIP18: Non-GC threads

Dmitry Olshansky dmitry.olsh at gmail.com
Sat Sep 1 05:39:40 PDT 2012


On 01-Sep-12 16:27, Peter Alexander wrote:
> On Saturday, 1 September 2012 at 11:37:39 UTC, Piotr Szturmaj wrote:
>> It's similar behavior to nothrow and pure. Instead of manually
>> avoiding GC allocations, compiler does this checks for you. Imagine D
>> doesn't have nothrow. You'd have to check every called function to see
>> if it doesn't throw. In big programs throwing function may be left
>> unnoticed and this is why we have static nothrow checks in D.
>
> I understand the benefit. However, there are at least two significant
> costs:
>
> 1. If I want my entire program to be GC free, I have to annotate every
> single function with 'nogc'. This is not something I want to do.
>

I'd say
@nogc:
at the top and deal is sealed.

> 2. It's a new language feature and has all the associated costs: initial
> implementation, bug fixing, marking up of functions in Phobos,
> documentation, etc.
>

> Yes, with my approach, a rare allocation may go unnoticed, and you end
> up with an undesirable GC collection sometime in the future. It's not
> great, but it's not the end of the world, and I'm willing to risk that
> to avoid the costs I mentioned above.


-- 
Olshansky Dmitry


More information about the Digitalmars-d mailing list