[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Why does coroutine.create return a thread?
- From: Andrew Starks <andrew@...>
- Date: Tue, 21 Jun 2016 09:24:31 -0500
My question is not about how to use Lua; it's about how to explain it.
I'm writing a tutorial on coroutines. I'm explaining what a coroutine
is, but feel that I need to explain the difference between it and the
value of type `thread` that is returned by coroutine.create. As a
newbie, I would expect a type of `coroutine` to be returned and since
it isn't, I assume that there is a distinction to be made.
Is a coroutine the function that you pass into `coroutine.create`?
Is a `thread` the execution environment that is running the coroutine?
thread = coroutine + stack + current state
I've used them many times but I'm not satisfied with my ability to explain them.