[Date Prev][Date Next][Thread Prev][Thread Next]
- 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 <email@example.com> wrote:
> On 9 July 2011 10:13, HyperHacker <firstname.lastname@example.org> wrote:
>> Just curious why, at least in Lua 5.1, one has to write:
>> instead of:
>> 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.