lua-users home
lua-l archive

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


> Hi,
> 
> I have been working on a TCP application server framework for Lua 5.2.
> Instead of creating my own I/O stream object, I'm using the luaL_Stream
> struct with the LUA_FILEHANDLE metatable in the following manner:
> 
> // int fd;  file descriptor of the network socket
> luaL_Stream *stream;
> stream = lua_newuserdata(L, sizeof(luaL_Stream));
> stream->f = fdopen(clonedfd, "b");
> stream->closef = my_close_stream_func;
> luaL_newmetatable(L, LUA_FILEHANDLE);
> lua_setmetatable(L, -2);
> 
> I have noticed that while this seems to work fine with Lua 5.2, it has
> not been part of its documentation but only been mentioned in the
> documentation of the upcoming Lua 5.3:
> 
> http://www.lua.org/work/doc/manual.html#luaL_Stream
> 
> Question:
> Is there any reason not to use this mechanism with Lua 5.2 already?

No reason. In 5.2 the "documentation" was the comments in lauxlib.h.

-- Roberto