What @xioren said: `spawn` returns a `FlowVar` and you have to wait for it to 
get your type.

As to your reading from `nil`, you have never constructed the `ref` which 
allocates it on the heap so it's still `nil` \- you can't deal with reference 
objects the same way as value objects just as in other languages you need to 
"new up" a reference.

Nim threading (and also async as was suggested) are in a state of flux right 
now as we move to the new memory management models of Arc/Orc: the old 
`FlowVar`'s in the threadpool library are very restrictive as to the types with 
which they work as are the arguments passed to `spawn` ([see the section in the 
experiment part of the 
manual](https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn));
 a new threadpool library built to work with the new memory management doesn't 
exist yet and I am in process of writing it.

The work around for now if you need to pass variables not compatible with 
`FlowVar`/`spawn` is to create pointers to the incompatible types and use those 
dereferenced. Messy, which is why we are moving away from it.

Reply via email to