Here a slightly less artificial example.
import random
import strutils
import threadpool
{.experimental: "parallel".}
proc genString(length: int): string =
for i in 1..length:
result.add(char(rand(int('a') .. int('z'))))
proc genSentence(n: int): string =
var ch = newSeq[string](n)
#var ch = newSeq[FlowVar[string]](n)
parallel:
for k in 0..ch.high:
let r = rand(3..9)
ch[k] = spawn genString(r)
#ch[k] = genString(r)
#for k in 0..ch.high:
# result = result & ^ch[k]
# result = result & " "
result = ch.join(" ")
echo genSentence(10) & "."
The compilation error is:
Error: type mismatch: got <FlowVar[system.string]> but expected
'TaintedString = string'
The code works fine if I don't use parallel (but do use FlowVars and read with
^)
Many thanks, Andreas