Thank you. The current Malebolgia state: import malebolgia type Count = object n: int v: int nseq: seq[int] func initCount(n, v: int): Count {.inline.} = #new(result) result.n = n result.v = v result.nseq = newSeq[int](n) func adder(c: var Count)= {.gcsafe.}: for i in 0..<c.n: c.nseq[i] = i + c.v proc updateCounts(ncList: seq[var Count])= {.noSideEffect.}: var m = createMaster() m.awaitAll: for i in 0..<ncList.len: m.spawn adder(ncList[i]) #Error: 'toTask'ed function cannot have a 'var' parameter when isMainModule: let n = 11 var nclist = newSeq[var Count](n) for i in 0..<n: nclist[i] = initCount(i, i*2) ncList.updateCounts() echo ncList.repr Run
and `weave`: import weave type Count = object n: int v: int nseq: seq[int] func initCount(n, v: int): Count {.inline.} = #new(result) result.n = n result.v = v result.nseq = newSeq[int](n) func adder(c: var Count) = {.gcsafe.}: for i in 0..<c.n: c.nseq[i] = i + c.v func updateCounts(ncList: ref seq[var Count]) = {.noSideEffect.}: init(Weave) parallelFor i in 0..<ncList[].len: ncList[i].adder() exit(Weave) # Error: 'ncList' is of type <seq[var Count]> which cannot be captured as it would # violate memory safety, declared here: [...]tread01.nim(72, 19); using '-d:nimNoLentIterators' # helps in some cases. Consider using a <ref seq[var Count]> which can be captured. when isMainModule: let n = 11 var nclist = newSeq[var Count](n) for i in 0..<n: nclist[i] = initCount(i, i*2) ncList.updateCounts() #Error: type mismatch Expression: updateCounts(nclist) echo ncList.repr Run not finished yet.