lua-users home
lua-l archive

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



On Apr 3, 2008, at 12:29 AM, Shmuel Zeigerman wrote:

Eugen-Andrei Gavriloaie wrote:
1.
lua_pushfstring(L, "return %s", expr);
and
lua_remove(L,-2);
Are used only for appending `return ` in front of the expression, right?

Yes.

2.
The lua_State *L will be reused (I need to read many things), so the end result script from memory will look like this after this sequence of calls from c++
--begin C++ code--
   lua_evaluate_expression(L,"#applications");
   ...
   lua_evaluate_expression(L,"applications[1].database.name");
   ...
--end C++ code--
--begin lua script represented from lua_State *L point of view --
... (original code from the file that was loaded from the very beginning) return #applications --this was added by the first call of lua_evaluate_expression return applications[1].database.name --this was added by the second call
--end lua script represented from lua_State *L point of view --
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.

3. I think the entire script will be executed entirely on each lua_evaluate_expression because of lua_pcall(L,0,1,0).

No.
Than what is executed on each lua_pcall(L,0,1,0)? Only the last added chunk of code (our artificially added returns)?


--
Shmuel