[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua persistent tables
- From: Ben Sunshine-Hill <bsunshin@...>
- Date: Tue, 18 Mar 2003 00:26:26 -0800
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