I am using Cent OS 7.
I want to write a program(written in Java or other languages) that can interact with Lua interpreter. I hope that my program can feed statements to Lua interpreter, and get executed real-time, while previous variables are still available.
For example, my program feeds a = 4; print(a);
to Lua interpreter 4
is printed on the screen. Then the program does other work. Later it feeds n = 0; for i=1,4 do n = n + i; end; print(n);
to the interpreter, and 10
is printed on the screen.
Note: All I want is that Lua interpreter execute the statements when my program feeds it one, while keeping its previous status. My program does not need to access variables in Lua interpreter.
I tried calling Lua interpreter separately, but it doesn't work as expected. Another solution is to record all previous statements, and run them before a new statement is going to run. But this is obviously not efficient.
Is there a easy way to do this? Such as just creating sub-process and making system calls?