What should happen here?

IGotD- nise at nise.com
Thu Sep 23 21:34:22 UTC 2021


On Thursday, 23 September 2021 at 19:54:56 UTC, Steven 
Schveighoffer wrote:
>
> You can. But wouldn't you prefer just pushing something on the 
> stack?
>
> I don't know, it sort of bugs me and fascinates me that there 
> isn't a way to do this easily. The stack is pretty much free to 
> use, adding something to some allocated tree inside the GC (and 
> then later removing it) isn't.
>
> The use cases are exceedingly small though...
>
> -Steve

It doesn't matter where it is, stack or register. What is 
important is that the pointer value is retained somewhere. 
KeepAlive should trick the compiler to believe that KeepAlive 
itself is a user of the resource. How that is done in practice is 
another question and may vary depending on GC type.


More information about the Digitalmars-d mailing list