-
Notifications
You must be signed in to change notification settings - Fork 997
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
How to deal with callables that are async in nature? #1105
Comments
if you want the async nature of the call to be hidden from lox then you will need to implement some coroutine functionality So you will need to be able to yield from the interpreter where the stack gets preserved and restored on the next resume. Or you can use the built in async/await you need to detect whether the return of a function is a Future and instead of returning it you need to await it (and make the entire interpreter callstack stack up to that point async) |
Hi,
I don't see a clear way to implement callables that are async. In my case I'm using a Dart implementation and I'm even willing to restrict the async functions to the
globals
(so all are predefined), say to get some data from a database. However, thevisitCallExpr
will return a Future that I can't await properly to preserve the sequential nature of a Lox script.For example, a global async function:
called from the Lox script
will print
Instance of Future<int>
, etc.If you can share any tips for a possible implementation it would be much appreciated.
Thank you!
The text was updated successfully, but these errors were encountered: