forcing weak purity
Steven Schveighoffer
schveiguy at yahoo.com
Wed May 23 07:01:12 PDT 2012
On Wed, 23 May 2012 09:56:58 -0400, deadalnix <deadalnix at gmail.com> wrote:
> Le 23/05/2012 15:52, Steven Schveighoffer a écrit :
>> What if memory is tight, and the only way to get memory for this new
>> allocation is to collect from the main heap? This seems an odd
>> limitation, since strong-pure functions would not be affected by
>> collecting in the main heap *at all*.
>>
>> -Steve
>
> It is up to the GC to collect memory when it is tight. This operation
> isn't and shouldn't be pure.
>
> It can eventually be called within the allocation mecanism.
Don has said that any collection cycle triggered by a pure function should
not touch the main heap, only memory allocated from within this function
(or 'pure function' stack I guess).
This means that a strong-pure function could throw an OutOfMemoryError,
whereas a non-pure one would run fine.
I'm with Alex on this, this situation is not tenable.
-Steve
More information about the Digitalmars-d
mailing list