lua-users home
lua-l archive

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


On Sunday 28 May 2006 12:51 pm, Jérôme VUARAND wrote:
> It's what I call a local function call (the call is local, not the
> function). And the only difference with the normal function call, is
> that inside the function, getfenv(2) returns a table of the local
> variables of the caller chunk (with eventually the real environment
> accessible in metatable __index of that table). That way the exact
> same implementation of my class function above would do what I want.

i've also wanted to see some way to 'inherit' local variables (for other 
purposes, not a class system); but using a table (even an environment table) 
wouldn't be optimal.  remember that local variables aren't in a table (unlike 
global variables), in the compiled bytecode local references are replaced by 
namless 'slots'.  

i imagine there could be two approaches to implementing your 'local call':

A: preserving the variable names, and creating a table and populating it at 
call time.

B: get rid of the whole 'slot' mechanism and replace it with lua tables, using 
the variable names as keys, just like global variables

either way, it's a big space and time bloat to all programs.  bit step 
backwards just to get one 'nice' feature

of course, i'd love if somebody (mike?) could optimize that so much to make it 
worth.

-- 
Javier

Attachment: pgpbFrxUEpGfU.pgp
Description: PGP signature