lua-users home
lua-l archive

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

Benoit Germain wrote:
I had a look at ldb, and the author implements breakpoints in a similar
fashion, and talks about "simulated local environment". His breakpoints are
of the form "function dummy (args) block end", evaluated, then lua_ref'ed,
and when a breakpoints location is hit, the reference is read and the
function evaluated. The author also uses lua_beginblock() and
lua_endblock(), which seems 3.x-specific. What does it do ? I suppose it is
equivalent to the pair int top = lua_gettop(L) / lua_settop(L,top) ? I also
see that when evaluating an expression, ldb takes all locals of the current
context, and makes globals of them, saving the masked global's value
somewhere, and restores those values after the expression is evaluated. Is
there really no other means to access local values ? I will do the same if
it is the only way, but if there is another solution I am interested :-)

You could also change the global table when you evaluate the exp, with a table with a 'index' tag method. This tag method can search first in the local environement if he can found the requested value, if he can't found it he search in the old global table.

Thomas Lavergne                       "Le vrai rêveur est celui qui rêve
                                       de l'impossible."  (Elsa Triolet)    ICQ:#137121910