[m-dev.] a chunk type?

Paul Bone pbone at csse.unimelb.edu.au
Thu Nov 1 16:28:33 AEDT 2007

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  
	  a chunk.

And probably others.

There is an io_combinator module in the deep_profilier which may be  
valuable to put in the standard library.  Along with other predicates  
in the read_profile.m module such as "read_n_things".


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