|  | ||
| 
 | 
| Nothing; the “ud=” assignment is the first thing that use() does.  L is a Lua state and “n” is the index into the stack at which the required userdata can be found. The whole function is: static local_t *_local_use(lua_State *L, int n) {     void *ud;     ud = lua_touserdata(L, n);     if (ud != NULL) {         if (lua_getmetatable(L, n) != 0) {             lua_getfield(L, LUA_REGISTRYINDEX, xstr_mt);             if (lua_rawequal(L, -1, -2)) {                 lua_pop(L, 2);                 return ud;             }             lua_pop(L, 2);         }     }     return NULL; } Although the thing sitting at index “n” had a metatable assigned to it in the lookup() function, it’s not there now; the second “if” always fails. As for your second question, the “lookup” might verify the existence of a key in a lookup table but not with any associated value.  The point then is to indicate the lookup succeeded, but has no other data to return. From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of liam mail On 21 July 2011 08:06, Murray S. Kucherawy <msk@cloudmark.com> wrote: use(m, y, n) Can you please post the code for 'use' ie what happens before "ud = lua_touserdata(L, n);", specifically where does 'n' come from. What are m and n which are passed from Lua to 'use'? off topic: "“lookup” actually is a registered C function that does a hash table lookup.  On a miss, “x” is set to false and “y” to nil; on a hit, “x” is set to true and “y” is set to a new userdata with a metatable assigned to it using:" Why do you use two values to represent the same thing. If y is valid then x is true and I would think 'x' is therefore redundant ? Liam |