In the original code, the **worker** proc is a _closure_. And **worker** does indeed access some of the variables in the surrounding context.
I think that passing a _closure_ to **spawn** is not allowed. Since all threads are potentially running within a separate memoryspace, I'm not even sure how this kind of sharing of variables could work in Nim. So this seems like a logical limitation. The C++ version does not use closures, neither does the version of @euant. So these versions should not have that problem.