I'm making a lisp dialect & I can't use any special syntax, only functions. I'm trying to add asynchronous programming.
I can turn a function into an asynchronous one using asyncio.coroutine
.
asyncio.run(asyncio.coroutine(lambda: print('Hello, world!'))())
I can also use asynchronous functions inside its body.
asyncio.run(asyncio.coroutine(lambda: asyncio.sleep(1))())
but the problem with that is that they will run in the background. So if by using a do
block, I execute asyncio.sleep(1)
two times, the program will wait only 1 second since both of them are running in the background.
This is when await
/yield from
is used in asynchronous programming, but it's a syntax & not a function, hence I can't use it. I'm looking for a function alternative.
ChatGPT couldn't solve it & I've taken a look at the following StackOverFlow posts.