On Thursday, 17 April 2014 at 19:51:38 UTC, Walter Bright wrote:
On 4/17/2014 10:41 AM, Dicebot wrote:
On Thursday, 17 April 2014 at 16:57:32 UTC, Walter Bright
wrote:
With current limitations @nogc is only useful to verify that
embedded code which
does not have GC at all does not use any GC-triggering
language features before
it comes to weird linker errors / rt-asserts. But that does
not work good either
because of next problem:
Remember that @nogc will be inferred for template functions.
That means that
whether it is @nogc or not will depend on its arguments being
@nogc, which is
just what is needed.
No, it looks like I have stated that very wrong because
everyone understood it
in completely opposite way. What I mean is that `put()` is NOT
@nogc and it
still should work. Same as weakly pure is kind of pure but
allowed to mutate its
arguments, proposed "weakly @nogc" can only call GC via
functions directly
accessible from its arguments.
I don't see value for this behavior.
It turns out to have enormous value. I will explain this in my
DConf talk. A little preview:
Almost all of our code at Sociomantic obeys this behaviour, and
it's probably the most striking feature of our codebase. By
"almost all" I mean probably 90% of our code, including all of
our libraries. Not just the 5% - 10% that could marked as @nogc
according to your DIP.
The key property it ensures is, if you make N calls to the
function, the number of GC allocations is in O(1). We don't care
if makes 0 allocations or 17.
We're not really interested in whether a function uses the GC or
not, since most interesting functions do need to do some memory
allocation.
Ideally, we'd want an attribute which could applied to *all* of
Phobos, except for some convenience functions. We have no
interest in library code which doesn't behave in that way.