lua-users home
lua-l archive

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


In Lua4.0 if there was an error in the text passed to lua_dostring an error 
message would be output and control would be returned to the calling 
application. With Lua5.0alpha the program simply exists so the calling 
application can not do anything. Does lua_load have the same behaviour?

Is this change likely to remain, and if so is there a simple way to execute 
potentially erroneus code without the risk of the program exiting. Currently I 
can only think of pushing a string on the stack and doing a pcall on 
loadstring, however this will not work where I only get the command in blocks, 
as can be done with lua_load.

The example code I am using is:
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  int retval;
  lua_State *state;

  state=lua_open(0); // state=lua_open() for lua5.0alpha
  lua_baselibopen(state);
  printf("Doing\n");
  retval=lua_dostring(state,"foobar(2,3)");
  printf("Done (%d)\n", retval);
  return(0);
}

Steven Murdoch.