[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Snag in custom debugger
- From: "Nick Trout" <nick@...>
- Date: Mon, 28 Apr 2003 19:12:25 -0700
cc>I would have expected local variables to be valid and in
>scope when calling lua_dostring within a line hook.
Lhf> Code run with lua_dostring is stand-alone code: it does not know
anything about being run within a line hook.
Try this: Create a table with the active locals at that point and set it
as the global table for running the code you run with lua_dostring.
Also, set an __index method (or index tag method) for this global table
to get things from the real global table. --lhf
It would be nice if Lua would create the local table for you. I'm not
sure but I think another side effect of locals being treated like this
is you cant apply metamethods to them like you can globals, e.g. so
local watchpoints arent as easy (or possible at all?). If you could get
a table of locals you could attach metamethods on a function hook and
local variables could be treated like the global scope (I have a feeling
its not that simple but I don't have time to check). I suggested adding
this a while ago but got no response:
http://lua-users.org/lists/lua-l/2003-01/msg00353.html
You can do this in Python using the locals() function. Additionally you
can execute Python code in a controlled environment by passing it the
locals and globals you would like the code to see.
Regards,
Nick