On Sunday, 18 January 2015 at 18:12:57 UTC, Zach the Mystic wrote:
http://wiki.dlang.org/DIP71
I want to keep this simple. There are three ways for a
reference passed to a function to escape that function.
static T* s;
T* fun(T* p1, T** p2) {
// escape by global
s = p1;
// escape by return
return p1;
// escape by mutable argument
*p2 = p1;
}
Because escape by return is by far the most common, adding
'return' parameters as in DIP25 clearly makes a lot of sense.
It just bugs me that the other two types of escape are still
possible. I think they shouldn't be. DIP71 introduces two new
attributes, "out!param" and "noscope" to address this.
I have a lot of other thoughts about this issue, but I want to
save them for a different thread.
If your function is marked as pure, then escape by global is
impossible.