News for hackers. Stuff that matters.
Re:Iodide: An experimental Mozilla tool for data exploration... by bayesian_horse on Wednesday March 13, 2019 @09:34PM (#19385776)
I was trying to make coroutines work through the javascript event loop, such that you could basically "await" any javascript Promise (or wrap a Promise in an awaitable).

So you'd have things like 'await sleep(1)' which would be implemented with a Promise and setTimeout. Or 'await fetch("/api/v1/list")'.

Unfortunately I haven't gotten very far yet.

Re:Iodide: An experimental Mozilla tool for data exploration... by KenoFischer on Wednesday March 13, 2019 @11:35PM (#19386339)
My preferred way to do this would be a compiler pass that rewrites everything to use the explicitly managed stack. I had started on writing that transform, but ran out of time. That's currently the major blocker for making the Julia/Iodide integration work well.
Re:Iodide: An experimental Mozilla tool for data exploration... by bijection on Wednesday March 13, 2019 @10:59PM (#19386176)
I'm pretty sure you can await any javascript Promise!

For example, running `await Promise.resolve(3)` in Chrome's js console prints `3`.

Re:Iodide: An experimental Mozilla tool for data exploration... by alexkavon on Wednesday March 13, 2019 @11:14PM (#19386257)
Also MDN has a fantastic Promise article with examples about wrapping a function with a promise.[0]

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Iodide: An experimental Mozilla tool for data exploration... by JonathonW on Wednesday March 13, 2019 @11:16PM (#19386267)
It's a little unclear, but I think he wants to integrate Python (Pyodide) coroutines into the JS event loop-- so async/await of Python code works seamlessly in the browser, and you can await Python code from within JS (and vice versa).

Any JS Promise is awaitable from JS; JS async/await is (more or less) syntactic sugar on top of promises.

Re:Iodide: An experimental Mozilla tool for data exploration... by bayesian_horse on Wednesday March 13, 2019 @11:49PM (#19386391)
Sorry, I meant to use "await" in Python to await Javascript Promises.