[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why coroutine can't be indexed?
- From: HyperHacker <hyperhacker@...>
- Date: Sat, 9 Jul 2011 08:58:10 -0600
On Sat, Jul 9, 2011 at 08:15, Michael Richter <ttmrichter@gmail.com> wrote:
> 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.
Mainly because Lua already uses this approach with strings, and most
libraries I can think of use it as well. e.g. with strings you can
write s:upper() instead of string.upper(s), but with coroutines
suddenly this doesn't work anymore.
Of course the same is true for tables but in that case there's an
obvious reason. I can't think of an obvious reason why it's this way
for coroutines? That one can easily do it with a metatable especially
makes me wonder why it isn't done by the library itself, as it is for
most objects in the Lua world. (A coroutine is an object, is it not?)
--
Sent from my toaster.