[m-dev.] a chunk type?
Paul Bone
pbone at csse.unimelb.edu.au
Fri Nov 2 13:59:09 AEDT 2007
On Thu, Nov 01, 2007 at 05:07:01PM +1100, Peter Wang wrote:
> On 2007-11-01, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> >
> > On 01/11/2007, at 4:17 PM, Peter Wang wrote:
> > >
> > > Actually I was thinking of
> > >
> > > :- type chunk ---> chunk(string).
> > >
> >
> > Although the system libraries (fread/fwrite) will do buffering I can see
> > this being useful when somebody wants to use records of particular lenghts,
> > or possibly for some other use cases:
> > + Reading delimetered text (CSV),
> > + Reading variable width records. say, read a header of a known size,
> > interogate it for the size of the body, then read that many bytes into
> > a chunk.
>
> Well, those imply that the underlying stream to respect the chunk size.
> My intention was that the underlying stream is free NOT to do that.
> e.g. if you are reading from a network socket, it would be best to
> return data whatever it's got handy, rather than blocking indefinitely.
>
> The problem I'm trying to solve is to efficiently read data out of a
> network socket to feed an XML parser. If the parser says there's not
> enough data, then we just go back and get more.
>
> Other uses might include efficient message digest or encryption
> routines, etc. Or just copying one stream into another.
>
Ah. Those seem like good uses. The same type could be used for any of
these uses.
I see no reason why not to introduce this type.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list