On Thursday, 16 March 2017 at 14:53:27 UTC, Eko Wahyudin wrote:
How D access xxx variable? where context pointer refer to?
How D keep xxx variable persistent?
Why xxx is not swapped out when we leave first delegate?

The compiler sees that you are going to reference the variable, and copies it to a heap buffer on function entry, so it uses that instead of the stack.

That heap buffer is reused across the delegates which is why it doesn't swap out (this is the same as Javascript's vars, but different than JS's `let` and C# and other languages).

  • How delegate context work? Eko Wahyudin via Digitalmars-d-learn
    • Re: How delegate context work? Adam D. Ruppe via Digitalmars-d-learn

Reply via email to