[m-dev.] streams proposal

Ian MacLarty maclarty at cs.mu.OZ.AU
Mon Jan 23 10:47:31 AEDT 2006


Hello,

I've come up with a new proposal for a streams library.  I believe this 
proposal addresses some of the shortcomings of the streams library in 
extras (for example one can define an efficient version of write_string 
that doesn't have to call write_char).

In my proposal an input or output stream is a typeclass with three type 
variables: the stream type, a `unit' type which is the type of the 
things that can be read or written to the stream, and a `state' type 
which is the type of the state that gets updated when reading or 
writing from the stream (this would typically be the io state, but 
could also be, for example, a string buffer).

I propose that the stream typeclasses go in a new library module called 
stream and that appropriate instances be defined in io.m and 
term_to_xml.m.  I think we should leave the IO operations in io.m as 
only working on io.input_stream and io.output_stream (for performance 
reasons), but io.input_stream and io.output_stream will be instances of 
the stream typeclass, so application developers will be able to develop 
predicates that work with general streams as well as io.input_stream 
and io.output_stream.

The attached file streams.m contains a rough draft of what the streams 
module will look like.

Comments welcome.

Ian.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stream.m
Type: application/octet-stream
Size: 4414 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20060123/f4cf438c/attachment.obj>


More information about the developers mailing list