Last active
October 30, 2024 15:42
-
-
Save ralt/57a3811ca7ed734295e87393b9964cbe to your computer and use it in GitHub Desktop.
Parenscript async/await support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ps::defprinter ps-js::await (x) | |
(ps::psw (string-downcase "(await ")) | |
(ps::print-op-argument 'ps-js::await x) | |
(ps::psw ")")) | |
(ps::define-trivial-special-ops | |
await ps-js::await) | |
(ps::define-statement-operator async-defun (name lambda-list &rest body) | |
(multiple-value-bind (effective-args body-block docstring) | |
(ps::compile-named-function-body name lambda-list body) | |
(list 'ps-js::async-defun name effective-args docstring body-block))) | |
(ps::defprinter ps-js::async-defun (name args docstring body-block) | |
(when docstring (ps::print-comment docstring)) | |
(ps::psw "async ") | |
(ps::print-fun-def name args body-block)) | |
(ps::define-expression-operator async-lambda (lambda-list &rest body) | |
(multiple-value-bind (effective-args effective-body) | |
(ps::parse-extended-function lambda-list body) | |
`(ps-js::async-lambda | |
,effective-args | |
,(let ((ps::*function-block-names* ())) | |
(ps::compile-function-body effective-args effective-body))))) | |
(ps::defprinter ps-js::async-lambda (args body-block) | |
(ps::parenthesize-at-toplevel | |
(lambda () | |
(ps::psw "async ") | |
(ps::print-fun-def nil args body-block)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be used as such:
And:
And: