code: func NewState() *State {
  	v := float64(VersionNumber)
  	l := &State{allowHook: true, error: nil, nonYieldableCallCount: 1}
  	g := &globalState{mainThread: l, registry: newTable(), version: &v, memoryErrorMessage: "not enough memory"}
  	l.global = g
  	l.initializeStack()
  	g.registry.putAtInt(RegistryIndexMainThread, l)
  	g.registry.putAtInt(RegistryIndexGlobals, newTable())
  	copy(g.tagMethodNames[:], eventNames)
  	return l
  }
docs: // NewState creates a new thread running in a new, independent state.
  //
  // http://www.lua.org/manual/5.2/manual.html#lua_newstate