[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: How can I hook into gc?
- From: "Michael Moore (GAMES)" <mdm@...>
- Date: Wed, 19 Nov 2003 22:10:59 -0800
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Nick Trout
Sent: Wednesday, November 19, 2003 9:58 PM
To: Lua list
Subject: RE: How can I hook into gc?
>> So why the '1' - what about my __index function? I guess that only
>> works if it can't find the thing in the table first -- which is ok
for
>> some things but sucks for other uses I might try to put __index to.
> You have a 1 in your table. You need to use an empty proxy table to
always get a query. From the manual:
I guess i was just thinking it would be nice if you could decide for
yourself if you wanted to allow pre-existing values to be returned or be
able to override the value returned at times. No big deal...
>> Suggestions? Helpful interpretations? Can I hook into the freeing
of
a
>> table somehow with the metatable, and if not why the heck not? :)
>Put a metatable on the table enclosing the table whose destruction you
want to catch. Use the __index MM to watch for the table being assigned
to nil, then bingo. I think that'll work.
I don't see how I can do that with __index or __newindex... looks like
they would both just silently assign nil and not inform me. I tried a
couple permutations but couldn't get it to go.
Any chance you have the time to give an example? S'ok if you don't -
we're all busy folks. :)
Thanks!
-mdm