lua-users home
lua-l archive

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


On Aug 29, 2010, at 9:33 AM, Francesco Abbate wrote:

> What I would like to do is to patch Lua to change this kind of
> behaviour. For me this is not a problem because a keep a copy of Lua
> as part of the repository. I would greatly appreciate if you or
> someone else in the list can give me some hints about which function
> of Lua should I touch to change this behaviour.

Untested. My guess would be that you could change the iscleared test on the key in cleartable in lgc.c so that it passes 0 for the second parameter thereby treating keys just like values.

--[[ Two other interesting points from skimming this code:

* isfinalized tells you that the object has been marked for finalization, not that it's __gc metamethod has actually been called. It's a reasonable behavior but the name is perhaps deceptive.

* This also looks to be roughly the place to teach the GC that strings need not be treated as values when it comes to weak tables. I don't know the consequences of doing so, but I do know that I've had cases where I've wanted weak sets of strings -- e.g., all of the strings that have been produced by going through the translation logic. Is there any known danger to adding an "s" option to the __mode entry to indicate that strings are to be treated as weak in this particular table?

]]

Mark