On Sun, 2004-08-01 at 21:48, Nicolas Cannasse wrote:
> > I just added a BigEndian module to IO that support read/write mulitbyte
> > operations using BigEndian representation (default ones are lowendian).
> > Regards,
> > Nicolas Cannasse
> Added the following to IO :
> val pos_in : input -> input * (unit -> int)
> (** Create an input that provide a count function of the number of bytes
> read from it. *)
> val pos_out : 'a output -> 'a output * (unit -> int)
> (** Create an output that provide a count function of the number of bytes
> written through it. *)
> They are quite useful and general purpose.
.. but you might add a cavet: they do NOT count the bytes
on the underlying channel, but only the bytes written
through this access path -- that is quite clearly specified
in your documentation, but it is something a programmer
might miss on first reading.
In particular if you make two objects from the same
Unix file handle, you can of course write from both
objects into the file .. the counts will not refect
the file size.. also of course the output will be scrambled
up by any buffering in the objects.
Generally, laziness can't work with interacting side-effects
such as writing to files -- whereas of course for functional
programming sharing is desirable to save space and time,
and has no impact, since the data is immutable.
John Skaller, mailto:skaller@...
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net