lua-users home
lua-l archive

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


On Sat, Jul 9, 2011 at 09:33, Dirk Laurie <dpl@sun.ac.za> wrote:
> On Sat, Jul 09, 2011 at 04:58:10PM +0200, HyperHacker wrote:
>> That one can easily do it with a metatable especially
>> makes me wonder why it isn't done by the library itself
> If this argument were valid for coroutines, it would apply equally
> to tables:  why must one say table.insert(list,item) instead of just
> list:insert(item)?
>
> To answer your question: it is not done by the library itself
> _because_ one can easily do it with a metatable.
>
> "Less is more" — Mies van der Rohe (1886–1969), architect.
>
> Dirk
>
>

I'm pretty sure it's not done with tables because list:insert(item)
already has a different meaning (to look up 'insert' in the table
'list'), and to set up a metatable like that could be confusing. (Why
t:insert() doesn't work? Oh, because t has a key named 'insert'
already... now is t2.insert a key in t2 or in table? etc)

-- 
Sent from my toaster.