lua-users home
lua-l archive

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


Dan East wrote:

>   Is there some non-trivial implementation issue that
> prevents an __assign metatable event within Lua?  Or is
> there some other mechanism already providing the same
> functionality?

It can currently be done with __newindex and a proxy table.
I don't see this explained in the wiki anywhere, but it is
on page 115 of Programming in Lua, if you have it.

Briefly, the idea is that the table the user assigns to is
always empty -- its __newindex metamethod does any
housekeeping you want done on every assignment, plus the
actual assignment to the real table (which the user never
directly accesses).

-- 
Aaron