lua-users home
lua-l archive

Re: (no subject)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> You'll find about this at the archives:
> http://lua-users.org/cgi-bin/namazu.cgi?query=attempt+to+index+a 
> +nil&sort=score&idxname=lua-l&max=20
The most relevant (and recent) thread about this starts at
	http://lua-users.org/lists/lua-l/2006-11/msg00636.html
In particular, see these answers:
	http://lua-users.org/lists/lua-l/2006-11/msg00639.html
	http://lua-users.org/lists/lua-l/2006-11/msg00645.html
If you need C code for this, here it is:
#include "lua.h"
static int indexnil (lua_State *L) {
 return 0;
}
LUALIB_API int luaopen_nil (lua_State *L) {
 lua_pushnil(L);
 lua_createtable(L, 0, 1);
 lua_pushcfunction(L,indexnil);
 lua_setfield(L, -2, "__index");
 lua_setmetatable(L, -2);
 return 0;
}
--lhf

AltStyle によって変換されたページ (->オリジナル) /