Interesting examples! Does the “made up data” always end up being zero or is that a consequence of the heap being essentially blank in these demonstrations?
Every language I’ve ever used came with a caution about iterating an array: be careful modifying it while you iterate.
Sometimes the behavior is undetermined! In C, etc, it’s not uncommon to see hacks which push stuff into an array in the middle of a while loop. For some reason especially in embedded code I’m used to seeing this kind of thing. It’s a clever algorithmic shortcut (clever here being a negative attribute).
I don’t think the goal of a concurrent stdlib needs to be “no footguns,” but I do think the paradigms need to be consistent enough and the footguns need to be well understood in the literature.
If plucking something out of an array while it’s being each’d results in a weird zero, that’s mostly fine with me. If it pulls data from memory or the heap somehow, then it seems like a roadmap to a zero-day exploit someday.