On Thursday, 17 April 2014 at 22:04:17 UTC, Walter Bright wrote:
On 4/17/2014 1:03 PM, John Colvin wrote:
E.g. you can implement some complicated function foo that
writes to a
user-provided output range and guarantee that all GC usage is
in the control of
the caller and his output range.
As mentioned elsewhere here, it's easy enough to do a unit test
for this.
Erm, no? You can possibly track GC calls by using custom druntime
fork but you can't track origins of such calls in source tree
without compiler help.
I hope Don's DConf talk will convince you how useful enforcing
such model is ;)
The advantage of having this as language instead of
documentation is the
turtles-all-the-way-down principle: if some function deep
inside the call chain
under foo decides to use a GC buffer then it's a
compile-time-error.
And that's how @nogc works.
And it is not good enough for practical reasons, i.e. we won't be
able to use @nogc for most of the Phobos.