[m-dev.] streams in Mercury

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Dec 14 01:07:15 AEDT 2005


Hello,

At MC we're using many different streams besides normal file streams
(such as sockets, ssl and logging streams).  Peter has therefore defined
some stream typeclasses and rewritten some parts of io.m for reading and
writing to general streams.  I now want to use the term_to_xml library
on streams besides normal file streams.  I don't, however, want to
maintain two copies of that code: one in the standard library that works
with io.output_stream and one in the MC repository that works with the
stream typeclasses.

I am therefore proposing that we add a stream module to the standard
library.  stream.m will define several stream typeclasses (such as
output, input and duplex) and implement all the predicates in io.m to
use the stream typeclasses.  io.m will then be rewritten to call the
predicates in stream.m (presumably we can specialise the predicates in
stream.m for the stream types in io.m like we specialise the 234tree
access predicates).  I would then rewrite the term_to_xml library to use
the stream typeclasses.  So the interface to io.m would remain
unchanged, but the interface to term_to_xml would change, but I don't
think that's too much of an issue, since term_to_xml is much newer.

Are there any thoughts on this idea?

I thought of using the new MercuryFile C type, but that approach has two
problems:
   1.  It requires writing C code to implement a new type of stream.
   2.  It requires the compiler to be built with a special flag to turn
       on the use of this structure.

stream.m would also need to keep a reference to the current stream, but
we can use mutables for that.

Ian.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list