lua-users home
lua-l archive

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



Reminds me of 'unpack()', which I think does not respect __index.

Lanes gives return values as h[1] etc. and if 'unpack()' respected __index one could simply 'unpack(h)' to get all the values.

-asko


On Sat, 5 Jul 2008 15:16:16 +0800
 "Alex Davies" <alex.mania@iinet.net.au> wrote:
Dr. Markus Walther wrote:

Question: Shouldn't table.insert/remove respect metatables (__index, __newindex) for reasons of symmetry and principle-of-least-surprise?

I've always thought the above. I think it's left around from old versions of Lua before metatables. Personally I'd prefer that everything respected them, from ipairs (should use __index) through to table.sort. Especially seeing as the speedup is minimal by performing raw access. Would make making proxy tables a lot easier, and as for compatibility, I'd say using these functions to deliberately avoid metamethods seems like incorrect use imo. My 2c :).

- Alex