lua-users home
lua-l archive

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


John Belmonte wrote:

1)  no hook for length operator (#) on table or string

This is a wart in Lua's extensibility, and often results
in complex and inefficient workarounds.

And Asko Kauppi wrote (elsewhere in the thread):

Now IF we only can get the '__len' metamethod to be
applied to tables (as it should, in my opinion...).

Maybe having __len be consulted for tables is a good
solution to the problem of sparse tables, but the fact that
it isn't is consistent with the behavior of other
metamethods; e.g., __add isn't consulted for numbers.  To
quote myself (page 268 of Beginning Lua Programming):

Metamethods serve mainly to define new behavior, not to
redefine existing behavior. Even the exceptions to that
rule are limited, which is why __eq only works with tables
or full userdatas, and why __newindex and __index only
work with nonexistent keys.

Lua team: what is the downside to making newproxy()
official?

--
Aaron
http://arundelo.com/

_________________________________________________________________
More photos, more messages, more storage?get 2GB with Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507