Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Coroutines are quite nice for managing sessions with asynchronous events, like stateful GUIs or client-server interactions. If you're familiar with the tendency of callbacks in e.g. JavaScript to nest deeply, you can think of coroutines as a way to recover a flat, procedural style.

I'm a particular fan of how coroutines work in Lua. Here's an article that helps explain them a bit in that context: http://leafo.net/posts/itchio-and-coroutines.html



Yeah, they're awesome for doing sequences of events that can have temporal gaps in the middle.

We used to use them(Lua) in games to do scripted sequences and AI. Was simple enough that even our designers could edit/extend them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: