DIP18: Non-GC threads
bearophile
bearophileHUGS at lycos.com
Fri Aug 31 19:40:16 PDT 2012
Piotr Szturmaj:
> This is done by adding nogc attribute for functions. nogc
> functions cannot perform operations that may allocate garbage
> collected memory.
I suggest to call that @nogc.
Time ago I have suggested a "@noheap" attribute for functions,
that is similar to that "nogc", see the discussion there:
http://d.puremagic.com/issues/show_bug.cgi?id=5219
The difference is that @noheap disallows C functions like C
malloc(), etc. Stack allocation like alloca() and variable length
arrays is allowed in @noheap functions.
@noheap/@nogc is probably inferred for templated functions, as
pure/nothrow.
The main disadvantage of an annotation like this is the
proliferation of kinds of functions. The advantage is a more
precise control of the effects of functions.
The Koka language has a function annotation similar to @noheap, I
have discussed a little about Koka here:
http://forum.dlang.org/thread/ocxmiolhlcysehbjtcop@forum.dlang.org
but Koka has type inference for effects, so often you don't need
to add that annotation to functions.
Bye,
bearophile
More information about the Digitalmars-d
mailing list