[m-dev.] io streams

Ralph Becket rbeck at microsoft.com
Mon Dec 27 23:27:49 AEDT 1999


> From: David Overton [mailto:dmo at hydra.cs.mu.oz.au]
> 
> What is the rationale for making stream__read_chars a type class
> method rather than just a polymorphic predicate that calls
> stream__reach_char to read in each character?  Is it for efficiency
> reasons?

One thing that comes to mind is that there may be more efficient
ways to implement read_chars than simply as a layer on top of
read_char.  For example, if I want to read several bytes/chars
from a Unix stream I would be inclined to use fread() rather than
a loop over getchar().  This sort of optimisation can be vital in
practice.

One point I would like to make, though, is that I don't think we
should be tying the interface to read_chars to lists of chars.
Rather, some sequence typeclass would be more generic and support
reading into e.g. arrays.  Although, as Fergus recently suggested,
it's probably a better idea to get the rest of the interface right
before generalising to sequences.

Cheers,

Ralph
--------------------------------------------------------------------------
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