Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Lua's GC only knows about references held within Lua, which is a reasonable implementation constraint. This implies that an object's lifetime is under Lua's control. If an object created by executing one script or function needs to be available to later scripts or functions, a reference to it has to be preserved within the Lua state so that the GC <em>knows</em> it is still in use. Otherwise, it is indistinguishable from garbage, and may be discarded at any time.</p> <p>This one of the purposes of the Lua registry table. The C side can easily hold a reference to any Lua object by placing it in the registry table. The key can either be some unique value known to the C library (the address of a <code>static</code> variable converted to a light userdata is often a good choice since it cannot collide with any key from any other library). Alternatively the function call <code>luaL_ref(L, LUA_REGISTRYINDEX)</code> will put the item at the top of stack in the registry table and return a unique integer key. This works well for storing a script-provided callback function in a way that both protects the function from the GC and allows a "pointer" (the integer key) to it to be stored in a C structure so that it can be retrieved and called later.</p> <p>Note that <code>luaL_ref()</code> can be used to manage references in any table, so it may very well make sense to use a table that is private to your module for the purpose rather than the global registry table. In this case, the table <code>ObjManager</code> itself might be a good candidate.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload