GC.addRange in pure function
vit
vit at vit.vit
Wed Feb 10 13:44:53 UTC 2021
On Wednesday, 10 February 2021 at 12:17:43 UTC, rm wrote:
> On 09/02/2021 5:05, frame wrote:
>> On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote:
>>> Why using 'new' is allowed in pure functions but calling
>>> GC.addRange or GC.removeRange isn't allowed?
>>
>> Does 'new' violate the 'pure' paradigm? Pure functions can
>> only call pure functions and GC.addRange or GC.removeRange is
>> only 'nothrow @nogc'.
>
> new allocates memory via the GC and the GC knows to scan this
> location. Seems like implicit GC.addRange.
Yes, this is my problem, if `new` can create object in pure
function, then GC.addRange and GC.removeRange is may be pure too.
Can I call GC.addRange and GC.removeRange from pure function
without problem? (using assumePure(...)() ).
More information about the Digitalmars-d-learn
mailing list