lua-users home
lua-l archive

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


On 9 July 2011 10:13, HyperHacker <hyperhacker@gmail.com> wrote:
Just curious why, at least in Lua 5.1, one has to write:
coroutine.status(co)
instead of:
co.status
and similar? The latter seems a lot more Lua-like.

I'm a little confused why you think using an object-oriented style of access is somehow more "Lua-like" when Lua is a *multi*-paradigm language that doesn't favour any single approach.  Basically you want Lua to be object-oriented, but Lua isn't an object-oriented programming language—unless you make it that way.  But you could just as easily decide to make it procedural or functional instead in your program should you so choose.

That being said, you can do metatable tricks, if you really want, to make your coroutines look like OOP objects.  This kind of stuff, however, should not be in what is Lua's standard library because not everybody wants to make their code OOP.  For that matter, not everybody wants to make their OOP code the same way.  After all you could have class+object OOP—both with and without inheritance—or you could have prototype-based OOP (and that's just off the top of my head here).  Hell, with a bit of work and a lot of trickery you might even be able to get Prolog-style logic programming, complete with unification, in Lua.  None of that, however, belongs in the standard library.

--
"Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.