[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: override assignment operator
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 17 Jan 2012 09:08:24 +0200
On Tue, Jan 17, 2012 at 8:27 AM, Jak Sprats <jaksprats@gmail.com> 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.