Open mratsim opened 4 years ago
Actually we probably need a sink
to allow chaining, and so the continuation is returned in a new variable.
let flowvar = spawn foo(a,b,c)
let continued = flowvar.then(bar(x, _, z).then(baz(_))
# flowvar is now invalid and we need enforcing at compile-time
# by disallowing `=`
alternatively (or both), we copy dup
semantics in a continueWith
macro
let flowvar = spawn foo(a,b,c)
let continued = flowvar.continueWith:
bar(x, _, z)
baz(_)
Motivation
It would be nice to support multithreaded continuations in the form of:
Syntax to be ironed out.
The
_
is a placeholder for the result of the first spawn to be passed tobar
reusing the convention fromdup
https://github.com/nim-lang/Nim/issues/14405.In terms of low-level, continuations can just be a syntax wrapper on top of the
FlowEvent
machinery. The "tricky" part is swapping the spawned FlowVar to the continuation flowvar but we might just require those to be mutable and disallow continuations onlet
Flowvar.