lua-users home
lua-l archive

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

On Tue, Sep 22, 2015 at 4:41 PM, Scott Morgan <> wrote:
> Seeing the following behaviour on various version of Lua:
> It's weird because, surely, if this is a bug, it has already been seen.
> It's such a common pattern. I must be doing something wrong here?

The __newindex metamethod is only triggered when the given index does
not already exist in the table. I believe the generally recommended
solution for catching every assignment is to use a proxy table, i.e.
keep the actual table empty and set up the __index and __newindex
metamethods to redirect accesses to another, hidden table.