What should happen here?

jfondren julian.fondren at gmail.com
Mon Sep 27 15:17:10 UTC 2021


On Monday, 27 September 2021 at 14:39:36 UTC, Max Samukha wrote:
> On Monday, 27 September 2021 at 13:59:57 UTC, Steven 
> Schveighoffer wrote:
>
>>
>> What I'm saying is, *if* you need a specific address saved for 
>> later in a function, wouldn't you prefer to store that on the 
>> stack rather than store it in the GC's roots? This would 
>> absolutely be opt-in, not automatic, as I don't see how we can 
>> do it automatically.
>>
>
> If performance was important, you would want to allocate the 
> object itself on the stack? The cost of GC allocation outweighs 
> that of GC.addRoot by a lot.

`scope` makes sense for the examples given but "I want this 
object to live at least as long as this variable's scope" and "I 
want this object to die at this end of this scope" are different 
desires.


More information about the Digitalmars-d mailing list