On Saturday, 30 November 2013 at 09:28:54 UTC, Namespace wrote:
DIP46 can help:
http://wiki.dlang.org/DIP46
Quote:
A further observation is that class GC has virtual functions in
it. This opens up the possibility of doing a gc_push() with a
different GC. Two possibilities come to mind:
1. Allocate-but-never-free, like DMD does. This would be very
fast.
2. Assert-on-any-allocation, used for code that wants to be
"nogc". This avoids the complexity of adding a "nogc" attribute
to D. More discussion of "nogc":
https://github.com/D-Programming-Language/druntime/pull/493
While having the ability to create 'tossable' regions of
garbage-collected memory would be fantastic (I would really love
to see that implemented), it does not completely solve the
problem that @nogc (and @noheap) tries to solve. The point of
@nogc is to have the compiler check for you that you didn't
accidentally make allocations. It works on the presumption that
you were trying to write allocation-free code. The
assert-on-allocation idea from DIP46 won't achieve this either,
as it leaves it to chance whether or not the execution of your
code will reach an allocating call. There's no guarantee there.