On 4/24/15 4:42 PM, deadalnix wrote:
On Friday, 24 April 2015 at 19:41:21 UTC, Steven Schveighoffer wrote:
On 4/24/15 3:12 PM, deadalnix wrote:
On Friday, 24 April 2015 at 18:48:43 UTC, Steven Schveighoffer wrote:
I think you are thinking of @safe-ty. malloc and free can be pure, but
must be contained properly.
purity when it comes to mutable data is a tricky thing.
No, it should not be pure because it alter global state in a manner
visible to the program.
But so does GC.malloc.
No, that's the whole point of using a GC. You ask it for a chunk of
memory, it gives you a chunk of memory. This does not affect any other
part of your program as it is a NEW chunk of memory, so you are not
messing with your program state.
But I can check memory usage size and see global state has been altered.
When you free, you potentially alter references anywhere outside your
"pure" function. It must not be pure.
When you do ANYTHING to mutable data, you potentially alter references
outside your pure function. This is not a disqualifier. It's accessing
global sate directly that wasn't passed to you that is a disqualifier.
-Steve