[m-rev.] diff: add function versions of io.stdin_stream and friends

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Nov 10 14:33:13 AEDT 2005


Estimated hours taken: 0.2
Branches: main

library/io.m:
	Add function versions of io.{stdin,stdout,stderr}_stream
	that do not take an IO state pair (the predicate versions
	do although they don't modify it).  We need the function
	versions so that we can give mutables of type io.input_stream
	or io.output_stream a meaningful initial value.

Julien.

Index: io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.336
diff -u -r1.336 io.m
--- io.m	23 Oct 2005 07:39:23 -0000	1.336
+++ io.m	10 Nov 2005 03:23:00 -0000
@@ -571,6 +571,10 @@
 :- pred io__set_input_stream(io__input_stream::in, io__input_stream::out,
     io::di, io::uo) is det.

+    % Retrieves the standard input stream.
+    %
+:- func io__stdin_stream = io__input_stream.
+
     % Retrieves the standard input stream. Does not modify the IO state.
     %
 :- pred io__stdin_stream(io__input_stream::out, io::di, io::uo) is det.
@@ -654,9 +658,17 @@
 :- pred io__set_output_stream(io__output_stream::in, io__output_stream::out,
     io::di, io::uo) is det.

+    % Retrieves the standard output stream.
+    %
+:- func io__stdout_stream = io__output_stream.
+
     % Retrieves the standard output stream. Does not modify the IO state.
     %
 :- pred io__stdout_stream(io__output_stream::out, io::di, io::uo) is det.
+
+    % Retrieves the standard error stream.
+    %
+:- func io__stderr_stream = io__output_stream.

     % Retrieves the standard error stream. Does not modify the IO state.
     %
@@ -6873,6 +6885,13 @@
 :- pragma export(io__stderr_stream(out, di, uo), "ML_io_stderr_stream").

 :- pragma foreign_proc("C",
+    io__stdin_stream = (Stream::out),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Stream = &mercury_stdin;
+").
+
+:- pragma foreign_proc("C",
     io__stdin_stream(Stream::out, IO0::di, IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
 "
@@ -6881,6 +6900,13 @@
 ").

 :- pragma foreign_proc("C",
+    io__stdout_stream = (Stream::out),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Stream = &mercury_stream;
+").
+
+:- pragma foreign_proc("C",
     io__stdout_stream(Stream::out, IO0::di, IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
 "
@@ -6889,6 +6915,13 @@
 ").

 :- pragma foreign_proc("C",
+    io__stderr_stream = (Stream::out),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Stream = &mercury_stderr;
+").
+
+:- pragma foreign_proc("C",
     io__stderr_stream(Stream::out, IO0::di, IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
 "

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list