How to avoid variable capturing in `foreach` loop with lambdas?

thebluepandabear therealbluepandabear at protonmail.com
Mon Jan 9 00:19:00 UTC 2023


> A nested function (or perhaps an inline lambda) is needed to 
> force the allocation of a dynamic context for the capture.
>
> This is an embarrassment. Why hasn't this been fixed yet? :-(
>
>
> T

I agree that this needs to get fixed immediately, it seems to be 
bugging me another time as well.

I believe I saw a similar StackOverflow post about this issue for 
C#, and Microsoft did fix it, hopefully D can do the same. Fixing 
this will improve the quality of the language for newcomers such 
as myself greatly.


More information about the Digitalmars-d-learn mailing list