Re: Metamethod when removing an index from a table?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Metamethod when removing an index from a table?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 6 Jun 2006 08:18:58 -0300
> I could use a proxy table and catch every access via __newindex, but I think
> the problem with that is the main table then doesn't behave right for things
> like pairs, because it's empty.
You can redefine pairs to work for proxy tables, say by honoring a __next
metamethod. See http://lua-users.org/wiki/GeneralizedPairsAndIpairs for a
C implementation, but it's easy to do it in Lua as well. --lhf