synchronized class bugs?

Gregor Mückl gregormueckl at gmx.de
Thu Apr 9 00:20:59 UTC 2020


On Wednesday, 8 April 2020 at 23:25:09 UTC, Steven Schveighoffer 
wrote:
> This works, because it captures the i value as a new variable 
> in a closure, so `val` remains constant while `i` increments.
>
> -Steve

Whooops... that was a major brain fart :(. Sorry for stealing 
your time.

Still, this makes me think about the rules for accessing 
variables in the outer frame in lambdas. I guess I'm used too 
much to the C++ rules that require explicit capture of everything 
and default to copying. At least @safe code should require 
explicit capture. There is no guarantee that a lambda is executed 
in the same thread.



More information about the Digitalmars-d mailing list