Support for top-level await
Hi! Awesome project!
I've taken the liberty to add support for await at the outer most scope.
I've also added some features here and there like
-
console.log/warn/errorto usekernel.print - syntax error messages
- use
util.inspectto print returned nested objects

If this looks right to you, i can issue a PR with the changes :grinning:
Here's the diff: https://github.com/3Nigma/nelu-kernelu/compare/master...legraphista:master
Thanks, @legraphista ! 💓
Here's my quick thoughts on your proposals/works:
- we chose to code Jupyter's log streaming functionality and make it available through
kernel.printinstead ofconsole.logto differentiate between terminal streams and UI ones when dealing with complex user-side logic. I would like to keep them apart mostly for semantic reasons (the jsconsoleis not to be confused with the Jupyter one). Now I do understand that this forces the developer to bind to the kernel's API which could make their code harder to execute in other non nelu-kernelu environments (wherekernelis not available, for instance). This could be fixed with some glue logic adapters (kernel.printtoconsole.log). Having said this, you do raise an important point here, and I think it's worth the effort investigating other ways of doing this without forcing the user to change their logic. In this sense, we are thinking of providing a command-line flag (eg.--log-to-ui) that would allowconsole.logs to get dumped into the UI instead of the process terminal. I'm curious of what your thoughts might be regarding this solution. - With regards to syntax error messages - I like it! We'll review the changes and carry on from there.
- And with what
util.inspectis concerned, we have issue #3 opened so go ahead and and open a PR, if you like/can. I think @RaduMilici will be more than happy to review it 👍
Let's continue this discussion in the upcoming days, but, yet again, thank you for your interest in the project. It's nice seeing people actually putting it to some good use/effort. 🙇
Hey @3Nigma!
Thanks for the reply! Allow me to quickly go through the talking points:
-
I understand the need for a differentiation between
kernel.printandconsole.log, but my first experience was a bit odd. I used Jupyter a lot with Python, and there you use the standardprintfunction to output to the interface, therefore my expectation was that I could also use the standardconsole.logto print to the interface. One could argue that a new user that hasn't seen/used Jupyter before and sets up this kernel, would expect the same behavior. The flag--log-to-uiwould be a good addition, though my suggestion would be to separate the console output of the kernel itself from the console output the user intended to see in the interface. Another small issue i see with the flag is that people don't fully read documentation, and they might skim through the part that enables theconsole.loginterface behavior and then be confused when it doesn't work. Maybe it could be enabled by default? -
Thank you! I've also noticed a branch PR that uses
babel, so maybe we could switchacornout for thebabelAST parser. -
~I'll open a PR with just that fix as soon as I can.~ https://github.com/3Nigma/nelu-kernelu/pull/10