From dadf30718d6084962be37dae8b94de41aaee90e2 Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Sat, 6 Mar 2021 22:09:22 +1100 Subject: [PATCH] Add io.write_line_cc/4. library/io.m: Add a version of io.write_line_cc that takes an explicit stream argument. NEWS: Announce the addition. browser/interactive_query.m: Use the new predicate. --- NEWS | 3 +++ browser/interactive_query.m | 3 +-- library/io.m | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 65a1b37f0..4562329fb 100644 --- a/NEWS +++ b/NEWS @@ -124,6 +124,9 @@ Changes to the Mercury standard library ### Changes to the `io` module +* The following predicate has been added to this module: + - pred `write_line_cc/4` + * The following obsolete predicates have been removed: - pred `make_temp/3` (replacement: `make_temp_file/3`) diff --git a/browser/interactive_query.m b/browser/interactive_query.m index e4e5f9419..a7c12fe82 100644 --- a/browser/interactive_query.m +++ b/browser/interactive_query.m @@ -940,8 +940,7 @@ write_binding(OutputStream, Bindings, Output, !IO) :- report_exception(OutputStream, Excp, !IO) :- io.write_string(OutputStream, "*** caught exception: ", !IO), - io.write_cc(OutputStream, Excp, !IO), - io.nl(OutputStream, !IO). + io.write_line_cc(OutputStream, Excp, !IO). %---------------------------------------------------------------------------% % diff --git a/library/io.m b/library/io.m index 772dfa1f0..219e9203d 100644 --- a/library/io.m +++ b/library/io.m @@ -1183,6 +1183,8 @@ :- mode write_line(in, in, in, di, uo) is cc_multi. :- pred write_line_cc(T::in, io::di, io::uo) is cc_multi. +:- pred write_line_cc(io.text_output_stream::in, T::in, io::di, io::uo) + is cc_multi. % Writes a binary representation of a term to the current binary output % stream or to the specified stream, in a format suitable for reading in @@ -8848,6 +8850,10 @@ write_line_cc(X, !IO) :- io.write_cc(X, !IO), io.nl(!IO). +write_line_cc(Stream, X, !IO) :- + io.write_cc(Stream, X, !IO), + io.nl(Stream, !IO). + %---------------------% write_binary(Term, !IO) :-