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

Knowing where async continuations occur? #14

Open
mike-kaufman opened this issue Feb 9, 2018 · 0 comments
Open

Knowing where async continuations occur? #14

mike-kaufman opened this issue Feb 9, 2018 · 0 comments

Comments

@mike-kaufman
Copy link
Owner

mike-kaufman commented Feb 9, 2018

One of the biggest problems now is knowing where async transitions happen. Is there a way to better communicate this through language constructs? e.g., instead of

var promise =
promise.then(function f() {
});

We could have

var promise =
promise.then(continuation f() {
});

This has several benefits as I think about it:

  • The notion that a function takes a “continuation” as an argument (instead of a function), makes it explicit in code where the transition occurs.
  • The “link event” can be updated to happen precisely when a “continuation” is created, thus the link happens closer to user code, vs buried deep inside some library.
  • We can better enforce async-transition semantics/correctness by having a clear distinction between a function and a continuation. E.g., we could assert that a continuation is invoked in a seperate context than where it was created.
  • this is a formalization of the pattern to wrap up a callback so it will propagate a callback, e.g., https://github.com/othiym23/node-continuation-local-storage#namespacebindcallback-context.

Now, this has implications on the language, which means it’s a bigger deal, but it’s such a fundamental concept that I wonder if it makes sense to pursue this. Nice thing is above is easily transpile-able & thus has a nice back-compat story.

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

No branches or pull requests

1 participant