lua-users home
lua-l archive

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


On 22/09/15 16:50, Javier Guerra Giraldez wrote:
> __newindex is a fallback, not an override.  that means that it's only
> called when the table doesn't have that index already.  that is, when
> it's a new index.
> 
> if you want to get all settings, you do a "proxy table", i.e. don't
> store in the object table itself, but on an different, internal table.

Ah, I follow, knew I was missing something simple. Misunderstood
newindex. Proxy tables for general stuff like this.

Would this also work for globals? Copy the contents of _G (using Lua 5.1
in this example) into a private table, nil out _G's entries and set it's
metatable to reference the private table.

Scott