Hmm, alright -- "it's by design". I copied out newfile() and io_closef() in my own project I wanted to be sure that I would not invite potential problems by rolling my own.
Not sure what I meant by manipulating file handle objects really, it's just important to be able to create files and close them. Because luaL_Stream/LStream wasn't in the manual and I had to go digging into the source it felt like something that was intended to not be used.
My point is that it might be nice to have these function to make sure that everyone creates their file handle userdatas in the same way (maybe it belongs it would go in the auxiliary lib?):
void * luaL_newfile(lua_State *);
void luaL_closefile(lua_State *);
FILE * luaL_getFILE(void *);
void luaL_setFILE(void *);
You're telling me I should perform those 4 steps (create the userdata, set the metatable, assign the stream to f, roll my own closef() and assign it) -- I'm saying this basic procedure will be done improperly by someone and we'll have the same issue. Instead of people rolling their own different file handle type we'll have the same userdata but improperly "formed". :>
newfile() should take care of assigning the internal io_fclose() function address, closefile() would be for closing the file without the user knowing how luaL_Stream is defined. getFile()/setFile() are just extras -- unnecessary of the LStream structure were documented in the manual...
I obsess too much, I think :\ Bad ideas?