[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: RFC: stream support on lua zlib binding
- From: Thomas Lauer <thomas.lauer@...>
- Date: Tue, 25 Mar 2008 18:20:36 +0000
"Tiago Dionizio" <firstname.lastname@example.org> wrote:
> I have been thinking - and doing some work - about adapting the zlib
> binding to be able to support zlib streams using a file like
While I can't comment on your actual proposal re zlib (I am using a
different library for that purpose) I'd like make a general remark which
may or may not be of interest in this context.
There are many occasions where a stream-based interface is (or could be)
used. Disk-based files (basically the functions in module io) are simply
a sort of standard case. Archive support, as outlined by you, is
another; memory-based files are yet another.
Wouldn't it be nice if the io module were layered and accepted, within
the functional framework already defined, "drivers" which implement the
actual I/O? These pluggable drivers would use the infrastructure of the
io module, both internally (ie code in liolib.c) and externally. File
access via the C runtime (as already implemented in io) would be
included by default but this would just be one of many possible drivers
which can use the io framework.
Installed stream drivers could be activated by calling io.open() with a
special first parameter. The exact semantics are of course debatable. Eg
as a string:
f=io.open("test.txt") opens a disk-based file, as usual.
f=io.open("memory:test") opens a memory-based file called test.
f=io.open("zip:test.zip:test.txt") opens a file in file test.zip