Coming from python (and the asyncio library), this is really confusing. It seems like a misunderstanding of generators and generator functions (yield) and coroutines (asyncronous programming). It makes no sense to replace yield with await. Yield returns a generator object and halts the execution of the function at the point of execution where yield was encountered. “yield” is just like “return”, except the local variables and point of execution are remembered, allowing you to call the generator function again to continue at the point that yield was last encountered. This allows you to loop over a generator function and gives you more control over the execution.
Generators are awesome. If you ever have a large list or array of items you want to loop over, storing the whole list in memory sometimes is not feasible and will crash your program. By using yield and a generator function, you only store one item of the list in memory for each iteration, which speeds up your program and saves a lot of memory. It seems like game development would benefit from this concept a great deal. (Looping over an array of enemy nodes to check for collisions etc.) With a generator, you could have an array of infinite objects and it would consume the same amount of memory as an array with 1 element.
Coroutines are what are returned when you call a coroutine function without awaiting it. You define a coroutine function by putting the keyword “async” in front of it. A coroutine is an awaitable, so to call it and get the return value, you use “await” or asyncio.run()
Coroutines and generators are totally separate concepts in python. There is such thing as an async generator, but thats just a generator with “async” keyword.
I know gdscript is not python, but it borrows so much from python that I get sad when it lacks certain elements that make python so great. (Such as list/dict/tuple expressions)
The choice to use yield and await like they are in gdscript just feels wrong. But it could just be me.