[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Interfacing lua with C
- From: "Peter Hill" <corwin@...>
- Date: Thu, 16 Jan 2003 02:31:09 +0800
>I didn't see a metamethod for the assignment operator in the
Luiz Henrique de Figueiredo:
> The metamethods are set for the table of globals, which you get using
> "getglobals()". Set "__index" and "__newindex" metamethods for this table.
> I see... but won't this interfere with normal lua variable assignment?
And if you want to make your C-synced variable local in scope then you've
got a problem. In fact, I think it can't be done. :-(
In essence, this is because Lua is untyped (the data has types but the
variables don't) so intercepting operations on variables (as opposed to
data) requires special treatment.
In Lua4 there was special treatment for global accesses. As globals are
stored in a Lua table, in Lua5 this was simplified by allowing access to
that table and using data access metamethods. Local variables, however, are
still left unhandled.