lua-users home
lua-l archive

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

E. Wing wrote:
> Thanks for the clarification. For lua_pcall, I've been providing my
> own error function that does a stack trace and saves the line number
> and file name. In the case of require(), this function wasn't being
> called so I assumed it was due to the luaL_loadfile. But it turns out
> that my error function doesn't get invoked in this case.
That strikes me as odd; pcall should catch any function thrown from
inside the state, whether from the top level or from anything it calls,
including require() itself and require()'d files.

> I realized I needed a separate Lua state anyway because it's not clear
> to me if the string library is loaded in my other state and if so, if
> a script didn't remove the 'string' table.
You can always save the string.* functions you need in the LUA_REGISTRY.
That guarantees they'll be around when you need them (provided you
aren't given guest scripts the ability to load binary modules or call
the debug library).
	Ben Kelly