2

Are keys set in the registry of a temporary state that's accessed in a module int luaopen_foo(lua_State*) adopted in the registry of the calling state?

For example, let's say we have this module:

int luaopen_foo(lua_State* state) {
    lua_pushstring("foo");
    lua_pushnumber(10);
    lua_settable(state, LUA_REGISTRYINDEX);
}

And this module is required by lua code:

require "foo"

Is the key foo in the registry from the state state adopted into the registry from the calling state?

Appleshell
  • 7,088
  • 6
  • 47
  • 96
  • 3
    The `state` argument passed to that function isn't a "temporary state" it is the lua state that is calling that function. – Etan Reisner Jun 12 '14 at 19:31

1 Answers1

0

If you want, write this in lua file

foo = require "foo"

fengxing
  • 374
  • 1
  • 4
  • 10
  • Oh of course, that's what I'd normally do. It was just not necessary in my example since nothing is pushed on the stack. (Your answer should be a comment, by the way.) – Appleshell Jun 14 '14 at 11:06