lua-users home
lua-l archive

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

On Apr 3, 2008, at 12:27 AM, Javier Guerra wrote:

On Wed, Apr 2, 2008 at 4:12 PM, Eugen-Andrei Gavriloaie
<> wrote:
So, on the second lua_evaluate_expression call from C++ I will have a value of 2 instead of the string 'mysql' pushed on the stack because the entire
script execution stops at the first return. Am I right?

no, each call to lua_evaluate_expression() would compile and execute a
new script in the same context. it won't 'accumulate' a long script.
Hmmm, that is even worse unfortunately because I don't want to recompile the script over and over again. Some Lua variables may contain valuable informations and on the first call of lua_evaluate_expression I will reset them. I'm talking about variables computed along the life of the lua_State like state variables for example. Further use of the lua_State will result in an unknown behavior (some state variables,if any, will be lost). This would work great on config files written in Lua since they should contain only initialized variables (much like a database, or a file with key/value pairs). But when you have to deal with Lua scripts that needs to be executed and they must have some state variables defined in them, will be a disaster.

 Thank you