lua-users home
lua-l archive

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

On Jun 10, 2009, at 5:24 AM, Luiz Henrique de Figueiredo wrote:

* VM: Add support for __overrideindex (as the meta-method's name
suggest, override a key in the table which already contains a non-nil
value with a new value, nil or otherwise)

The usual answer is to use proxies.

Proxies work well for a fair number of things, except for some types of lazy evaluation like accessing tables in a remote Lua environment. If one wants to do things like call functions in the remote environment, but also be able to index values on remote tables and have them be able to be accessed locally, it is difficult to decide when a series of __index events should result in returning another proxy vs returning the value on the table.

Say for example you have a handle for the remote environment, conveniently called "handle":,b,c)

It's pretty easy to know how to deal with this situation since it includes a call, but what if that same remote table called foo has a value on it that I want:

local_value =

Do I make local_value a proxy or the actual value? The metatable hooks allow for dealing with a number of operations, but what if I just want to do somehting like:


It would be nice to be able to hook things maybe at the index2adr level, or provide some way so that when the actual type is checked or looked up that the value could be pulled down just before the operation.

Some of this functionality could come from adding a __tonumber, and covering a few more type conversions, but this would provide a more general lazy evaluation hook.

I assume it would also potentially slow down every lookup for data, but perhaps there's some way to make that hit negligible?

James Snyder
Biomedical Engineering
Northwestern University
ph: (847) 448-0386

Attachment: PGP.sig
Description: This is a digitally signed message part