Skip to content

Instantly share code, notes, and snippets.

Last active Jan 17, 2021
What would you like to do?
Parenscript async/await support
(ps::defprinter ps-js::await (x)
(ps::psw (string-downcase "(await "))
(ps::print-op-argument 'ps-js::await x)
(ps::psw ")"))
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)
,(let ((ps::*function-block-names* ()))
(ps::compile-function-body effective-args effective-body)))))
(ps::defprinter ps-js::async-lambda (args body-block)
(lambda ()
(ps::psw "async ")
(ps::print-fun-def nil args body-block))))

This comment has been minimized.

Copy link
Owner Author

@ralt ralt commented Aug 20, 2019

To be used as such:

(async-defun foo ()


(let ((bar (await (foo))))


(async-lambda () (await (foo)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment