Dear all,
I would like to use
[parallel](https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn-parallel-statement)
and am running into unexpected compilation problems, apparently because the
procedure in question returns a string. An artificial example is given below.
For this I took the normally perfectly fine working code (if it returns a
float) for efficiently computing pi from the
[docs](https://nim-lang.org/docs/manual_experimental.html#parallel-amp-spawn-parallel-statement)
and made it return a string:
import strutils, math, threadpool
{.experimental: "parallel".}
proc term(k: float): string =
var f = 4 * math.pow(-1, k) / (2*k + 1)
result = $f
proc pi(n: int): float =
var ch = newSeq[string](n+1)
parallel:
for k in 0..ch.high:
ch[k] = spawn term(float(k))
#for k in 0..ch.high:
# result += ch[k]
result = ch[0]
echo formatFloat(pi(5000))
This obviously doesn't do anything, but it does trigger the compilation error:
Error: type mismatch: got <FlowVar[system.string]> but expected
'TaintedString = string'
I don't quite understand what's going on. Using TaintedString and switching
taintMode on or not, doesn't change anything.
Could someone please help?
Many thanks, Andreas