lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Friday, August 29, 2014, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2014-08-29 15:41 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:

> A "coroutine" is the function that is the value you give to "coroutine.create".
...
> The only thing that makes a function a coroutine is that it is being used as
> an argument for create.

Can't agree here.

Quote from the Lua 5.2 manual, in the documentation of create:

   Returns this new coroutine, an object with type "thread".


I stand corrected (although object seems like the wrong word, given that there are no methods on it. You can't do "my_thread:status()", although that's not a horrible idea, so long as threads could also have their metatable individually re-assigned)

I think that my confussion lies in the _expression_ of the feature as "coroutines" and the fact that there aren't any of those in Lua. There are functions, threads, etc.

I do not suggest any changes here (except for the change to the error reported by status). 

But, it does remind me of tables and the __index metamethod pointing to a table with string keys pointing at function values. We may call them objects, but Lua only knows about tables. (Accepting table:method()).