lua-users home
lua-l archive

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

On Wed, Jun 22, 2011 at 12:21 AM, Luiz Henrique de Figueiredo
<> wrote:
> All feedback welcome. Thanks.

Just an observation about the folly of depending on undocumented internals.

Previously people could hijack the existing file objects by packing
their own FILE* in the LUA_FILEHANDLE userdata, which was just FILE**.
 Now that userdata looks like this:

typedef struct LStream {
   FILE *f;  /* stream */
   lua_CFunction closef;  /* to close stream (NULL for closed streams) */
 } LStream;

(LuaJIT uses something similar)

I mention this because I think there's a need for a standard way for
extensions to create Lua file objects, or even on level of a
'io.fdopen' function that would create a file object from an existing
file-like handle.  One particular use case would be a Windows
extension wishing to provide a UTF-8 aware, or to redefine
io.popen so it does not depend on the particular broken implementation
of the Windows CRT.

steve d.