title: What is the difference between Lua registry with light userdata and references?
body: <p>So with the Lua C API you can save a Lua value in the registry and retrieve it later. There are different ways to do it, you can create a variable and use it's pointer as the key in the registry as it's always unique. You would push the pointer as light userdata.</p>
  
  <p>You can also create a reference using <code>LuaL_ref(L, LUA_REGISTRYINDEX)</code>. What is the advantage of one over the other? When to use references and when to use pointers?</p>
  
  <p>Also with references, as it is called a reference, if the Lua garbage collector collects the Lua value, will the value in the registry be <code>nil</code>? What if Lua updates the Lua value, will the value in the registry also change?</p>