lua-users home
lua-l archive

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

On Tue, Jan 17, 2012 at 8:27 AM, Jak Sprats <> wrote:
> So I need to do something like override the assignment operator for a
> variable, but I cant figure out how.
> Anyone got any magic on this one?

Strictly speaking, you can't override assignment to a single variable.
 However, assignments of the form 't.v' will cause __newindex to fire,
if 'v' is not already present in t.  So the solution is a variation on
the proxy trick;  t does not directly have your variables, but
__newindex can redirect the lookup to some hidden table within t,
_and_ fire a notification.

steve d.