[m-dev.] Stream2000

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 17 17:06:01 AEDT 2000


On 16-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> On Wed, Nov 15, 2000 at 08:54:13PM +1100, Fergus Henderson wrote:
> > 	I would much prefer to have a pure stream.lowlevel.m that
> > 	provides everything that stream.impure.m provides except the
> > 	impurity.  I wouldn't mind having stream.impure.m so long as
> > 	stream.lowlevel.m is there, but I object to having
> > 	stream.impure.m in the public interface without
> > 	stream.lowlevel.m being there, since it would encourage people
> > 	to make unnecessary use of impurity.
> > 
> > I am not inclined to compromise on that one ;-)
> > 
> Having a pure lowlevel interface would require that you add io__state
> pairs.  This then requires that you make all the typeclass methods det
> and thus would require returning an extra argument which is whether or
> not the operation succeded,

Right.

> at which point I believe that the actual
> interface would differ only slightly from the highlevel interface in
> stream.m

That may well be true.

> and hence not worth implementing.

Here I disagree.  If the impure low-level interface is worth
implementing, then the pure version is worth implementing too, because
otherwise people might be encouraged to use impure code, which would
make their code harder to read and maintain.

The documentation for the impure version says the following:

% This file provides throwing exceptions, grabbing error messages,
% results packaged into ok/error/eof, and turning C style handle based
% IO into Mercury di/uo.  That's all it does, but it's something you'll
% have to do and get right every time you implement a stream, so we have
% done it for you.

Of these things, the last one (turning C style handle based IO into
Mercury di/uo) is trivial.  If the other things are worth doing, then
provide a pure interface for doing it.

I don't mind if people provide impure ways of doing things *in addition*
to providing a pure interface that does the same thing.  But I will
object to anyone providing some useful feature with *only* an impure
interface, unless that's the only way it can be done (which is not the
case here).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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