Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support continuations #151

Open
mratsim opened this issue May 20, 2020 · 1 comment
Open

Support continuations #151

mratsim opened this issue May 20, 2020 · 1 comment

Comments

@mratsim
Copy link
Owner

mratsim commented May 20, 2020

Motivation

It would be nice to support multithreaded continuations in the form of:

let flowvar = spawn foo(a,b,c)
flowvar.then(bar(x, _, z))

let r = sync flowvar

Syntax to be ironed out.

The _ is a placeholder for the result of the first spawn to be passed to bar reusing the convention from dup nim-lang/Nim#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 on let Flowvar.

@mratsim
Copy link
Owner Author

mratsim commented May 20, 2020

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(_)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant