evaluating expression in the local scope (during debug)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

evaluating expression in the local scope (during debug)

Roman Vanicek
Hello,

I have made a simple debugging tool to help me develop Lua scripts and I
came upon this problem.

I have set up the debug hooks, this works fine. But when I call lua_dostring
inside them, the string is evaluated in the global scope (ie. local
variables are hidden to it). I would need to evaluate it in the local scope
instead (at the spot I am located in the debugging process). Is there any
reasonably easy way to do so?

Roman
[hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: evaluating expression in the local scope (during debug)

Tomas-14
> I have set up the debug hooks, this works fine. But when I call lua_dostring
> inside them, the string is evaluated in the global scope (ie. local
> variables are hidden to it). I would need to evaluate it in the local scope
> instead (at the spot I am located in the debugging process). Is there any
> reasonably easy way to do so?
	I've almost finnished the new version of the Lua Debugger, where
there is a solution to that problem.  I think the easiest way is to copy
all locals at globals, then evaluate the string and after all update the
locals.  This is implemented in the function Y.localdostring at the new
package (now it is called yield).  I'll update Ldb's page and create a new
one in some minutes:

http://www.tecgraf.puc-rio.br/~tomas/yield

	Remember: this is still alpha version!  I will appreciate comments
and any suggestion.
		Tomas

Reply | Threaded
Open this post in threaded view
|

Re: evaluating expression in the local scope (during debug)

Bill Whiten
In reply to this post by Roman Vanicek
>Hello,
>
>I have made a simple debugging tool to help me develop Lua scripts and I
>came upon this problem.
>
>I have set up the debug hooks, this works fine. But when I call lua_dostring
>inside them, the string is evaluated in the global scope (ie. local
>variables are hidden to it). I would need to evaluate it in the local scope
>instead (at the spot I am located in the debugging process). Is there any
>reasonably easy way to do so?
>
>Roman
>[hidden email]

This raises the question of the design decision to have variables
automatically global instead of local as in most other languages where the
use of global variables is strongly discouraged.

What comments on this?

Regards,

-----------
Bill Whiten,                                     [hidden email]
Julius Kruttschnitt Mineral Research Centre,     [hidden email]
The University Of Queensland,                    Tel: int +61 7 3365 5888
Isles Rd, Indooroopilly,                         Fax: int +61 7 3365 5999
Brisbane Qld 4068, AUSTRALIA.



Reply | Threaded
Open this post in threaded view
|

Re: evaluating expression in the local scope (during debug)

Luiz Henrique de Figueiredo
In reply to this post by Roman Vanicek
>This raises the question of the design decision to have variables
>automatically global instead of local as in most other languages where the
>use of global variables is strongly discouraged.
>
>What comments on this?

This has been discussed heatedly before. See the archives.
--lhf