lua-users home
lua-l archive

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


Mark Edgar wrote:
You don't think it's bad style to add (get|set)_timeout to the file userdata
methods? Not trying to criticize, just interested in your opinion.

Not as long as your new methods fail properly when called with
non-pipes.
Fair enough :)

If you want to integrate pipes so that they can be used
wherever a file is expected (and this seems a good thing) then you
must use the same metatable.
Must? You /are/ talking about code I'm writing, right? As of yesterday[1] my tofile() helper[2] checks for either of the file/pipe metatables. Does this not give the same functionality? If so, I have overlooked something...

This is basically the same thing I've done with pipes in the "ex" API
too, by the way.  It might be nice if there was also an API which did
the same thing for network connections too.
Not sure I can make APR's sockets as easy as files and pipes but I'm planning to at least give it a try. I think it would really fit Lua to make APR's file/pipe/socket i/o interface obey the same interface *subset* (using separate but `compatible' metatables allows additional methods so I don't have to dumb down the interface just to make it compatible).

Note that I know nothing at all about APR and its abstractions.  It
might not make sense to attempt to unify the APR API and the Lua API.
I can always try! We'll see how it works out.

 - Peter Odding

[1] http://lua-users.org/lists/lua-l/2007-04/msg00324.html
[2] the name is really a misnomer now, obviously