lua-users home
lua-l archive

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

I'm enumerating local vars with:

    lua_Debug debug_info;
    int level = 0;
    while (lua_getstack(ls, level++, &debug_info) == 1)
        const char* tmp = 0;
        int i = 1;
        while ((tmp = lua_getlocal(ls, &debug_info, i++)) != NULL)

            lua_pop(ls, 1);

my lua-script is:

	local val = nil

	local val = exampleGet()


when enumerating on the 3. line, I get two variables 'val', one nil and one number. why is that?

Am 02.06.2011 13:45, schrieb Luiz Henrique de Figueiredo:
If there was a way to plug into global name lookup in the compiler, we
could accurately describe to the compiler what global variables exist

See a patch in

This has often been mentioned here before. See these threads:

It might even be possible to compile expressions such as string.byte
to a constant reference in the byte code, so that the need for the
"local byte = string.byte" pattern goes away.

This is not hard to do with token filters.