[m-dev.] io streams

David Overton dmo at hydra.cs.mu.oz.au
Thu Dec 23 12:50:44 AEDT 1999


On Thu, 23 Dec, 1999 at 11:24:17AM EST, Michael Day wrote:
> 
> 	% Interface for input streams.
> 
> :- typeclass stream__input(S) <= stream__stream(S) where
> 	[
> 		pred stream__read_char(stream__result(char), S, S),
> 		mode stream__read_char(out, di, uo) is det,
> 
> 		pred stream__read_chars(stream__result(list(char)), int, S, S),
> 		mode stream__read_chars(out, in, di, uo) is det,
> 
> 		pred stream__read_chars(stream__result(list(char)), S, S),
> 		mode stream__read_chars(out, di, uo) is det,
> 
> 		pred stream__putback_char(char, S, S),
> 		mode stream__putback_char(in, di, uo) is det
> 	].

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?

> 
> %-----------------------------------------------------------------------------%
> 
> 	% Interface for output streams.
> 
> :- typeclass stream__output(S) <= stream__stream(S) where
> 	[
> 		pred stream__write_char(char, S, S),
> 		mode stream__write_char(in, di, uo) is det,
> 
> 		pred stream__write_chars(list(char), S, S),
> 		mode stream__write_chars(in, di, uo) is det,
> 
> 		pred stream__write_chars(list(char), list(char), S, S),
> 		mode stream__write_chars(in, out, di, uo) is det,
> 		mode stream__write_chars(di, uo, di, uo) is det,
> 
> 		pred stream__flush_output(S, S),
> 		mode stream__flush_output(di, uo) is det
> 	].
> 

Ditto for stream__write_chars.


David
-- 
David Overton       Department of Computer Science & Software Engineering
PhD Student         The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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