lua-users home
lua-l archive

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

> I guess the Lua authors have already considered this possibility
> (because it's so simple to implement), but probably rejected it.

One problem is that it does not extend nicely to tables. If you could
write "s:len()", it would be quite reasonable to expect "t:next(k)" to
work as well. However, to have a default metatable for tables has two
drawbacks (at least):

- a change in that metatable could affect the behaviour of the whole
program in subtle ways (e.g., making all tables not to return nil for
absent fields).

- once a table gets its own metatable, you cannot operate on it as
"expected" (that is, "t:next(k)" won't work on that table anymore).

-- Roberto