On 4/25/15 11:06 PM, deadalnix wrote:
On Friday, 24 April 2015 at 23:27:36 UTC, Steven Schveighoffer wrote:
pure function can access global immutable state that wasn't passed to
it, so you may want to revise your definition.
Sure: s/accessing/altering, my mistake.
That is the whole point. See it as follow: GC.malloc create new state.
As long as this new state doesn't escape the pure function, it is as if
that state was local.
I get that, you can apply the same thing for free. No reason this can't
be a pure function:
void foo()
{
int *x = cast(int *)malloc(sizeof(int));
*x = 0;
scope(exit) free(x);
}
But there are other problems, as I pointed out in another post.
-Steve