lua-users home
lua-l archive

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


2010/8/29 Mark Hamburg <mark@grubmah.com>:
> 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.

Great great great!!! Thanks a lot Mark!! :-)

Actually it seems that the "bug" I'm complaining about is a "feature"
because the code does intentionally keeps, during the current gc
cycle, the pairs if the collected object is a key.

As far as I know this behaviour is also undocumented because I didn't
read anything about that in the reference manual. Probably it was done
because, as you suggests, some code may want to access the table and
find the data in the __gc metamethod itself (?).

So I've easily fixed the problem as you suggested, I've changed the
function "iscleared" to work like if the parameter iskey was always
false. I've already made some tests and now everything works like it
should!

Thank you very much to everyone for the help. I understand that this
is a rather obscure point and it does not interest most people here
but I think it is nevertheless pertinent to the mailing list and it
can be interesting for some (very picky) people :-)

Cheers,
Francesco