GC.addRange in pure function

rm rymrg at memail.com
Wed Feb 10 12:17:43 UTC 2021


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.


More information about the Digitalmars-d-learn mailing list