Let's get the semantic around closure fixed.
Paul Backus
snarwin at gmail.com
Tue May 18 18:51:40 UTC 2021
On Tuesday, 18 May 2021 at 17:53:20 UTC, Ola Fosheim Grostad
wrote:
>
> Does a delegate do anything more than retaining a pointer to
> the stack record?
> Anyway, it should not escape the scope it references. So escape
> analysis is your friend.
The compiler does escape analysis and pre-emptively allocates any
variables that escape through closures on the GC heap.
The bug here is that, for variables declared in loop bodies, the
compiler *should* allocate a new copy on the heap for each loop
iteration, but instead it only allocates one copy that's reused
across all iterations.
More information about the Digitalmars-d
mailing list