lua-users home
lua-l archive

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


Search the list archives for "proxy tables"... the basic idea is that 
everytime an element gets added, the metamethod moves it out of the table and 
into another one.

Ben

On Tuesday 18 March 2003 12:18 am, Steven Frank wrote:
> I ported the Lua persistent tables example:
>
> http://lua-users.org/wiki/PersistentTables
>
> ...to Lua 5.0, but I noticed there is a fundamental flaw -- the
> __newindex metamethod is only called if the current value at the index
> is nil.
>
> Ie; it only works if you do this:
>
> persistent_table[0] = nil
> persistent_table[0] = "new value"
>
> If you miss the first line, and that index already has a value, the new
> value doesn't get saved...   Any ideas?
>
> Steven