lua-users home
lua-l archive

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

If you look at line 487 of table.c, you will see that Lua already does just as you suggest
with the fasttm cache flags.

I'm going way out on a limb here, but as far as I know, the admonition only applies to the __mode key
(at least that is the text I found in the manual); changing the weak mode of a table which already has
elements is likely to lead to undefined (if not undefinable) behaviour.

So the only issue I can see is that changing a metatable will clear the cache flags, which may
have some minimal short-term performance impact.


Mark Hamburg <>
Sent by:

03/25/04 09:29 PM
Please respond to Lua list
Size :3 Kb

        To:        Lua list <>
        Subject:        Changing metatable contents

We've been looking at some data loading issues on my team, and the issue
that you shouldn't change metatable contents (or at least not which keys are
present) has come up. Is there a reason for this admonition other than an
artifact of the implementation? Could it be removed by clearing the fasttm
cache flags whenever we set an entry in a table?