lua-users home
lua-l archive

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


on 10/14/04 2:02 PM, Rici Lake at lua@ricilake.net wrote:

>> More importantly make these metamethods *always* override default
>> ones. This
>> is the simplest and most general way on which everything else can be
>> built
>> and concerns index/newindex AFAIK. I can see no reason for their
>> current
>> behaviour which requires a trick to bypass.
> 
> The current behaviour is more efficient and often exactly what is being
> looked for, particularly in the case of __index. (In the case of
> __newindex, the point is arguable.) The use of a proxy table is not
> really a "trick"; it is a Lua idiom :) Of course, metatables applied to
> userdata already do exactly what you want.

Or more explicitly, always calling through __index interferes with
implementing schemes that provide simple, prototype-based inheritance
between tables.

I don't know what the case is for the behavior of __newindex.

The unfortunate thing about proxy tables is that they break for many other
operations such as iteration, insertion, etc. unless one knows that one is
dealing with a proxy table and uses different operations.

Mark