lua-users home
lua-l archive

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


> I'm upgrading to Lua 5.2.1 from 5.1.4 and am having difficulty finding examples on how one  defines 'classes' in 5.2 without using LUA_COMPAT_MODULE.

See my libraries at
	http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/

lbc and lrandom should be easy enough to understand. Just be aware that
I'm lazy and I use the library table as the metatable for the objects it
creates.

>   luaL_getmetatable(L, test_class_name);
>   lua_setmetatable(L, -2);

In Lua 5.2 you can replace those lines by luaL_setmetatable(L,test_class_name).