[m-dev.] a chunk type?
Peter Wang
novalazy at gmail.com
Thu Nov 1 17:07:01 AEDT 2007
On 2007-11-01, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
>
> On 01/11/2007, at 4:17 PM, Peter Wang wrote:
>
> > On 2007-11-01, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> >> Peter Wang, Thursday, 1 November 2007:
> >>> Hi,
> >>>
> >>> Does anyone have any objection to adding a string.chunk type, analogous
> >>> to the string.line and string.text_file types? The intention is to be
> >>> able to use stream.get to read some arbitrary number of characters out
> >>> of a stream. The number could be just something convenient for the
> >>> stream, or some stream types could provide predicates to record the
> >>> desired chunk size.
> >>>
> >>> Better ideas?
> >>
> >> I'm presuming you're thinking of a wrapper around a bit_buffer?
> >
> > 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.
Peter
--------------------------------------------------------------------------
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