[m-rev.] For review: Introduce string.sv_append/3

Paul Bone pbone at csse.unimelb.edu.au
Fri Jul 25 10:55:37 AEST 2008


For review by anyone.

Estimated hours taken: 0.1
Branches: main

library/string.m:
	Introduce an alternative to string.append/3, namely string.sv_append/3
	which takes it's first two arguments in the opposite order so it can be
	easily used with state variables. 

Index: library/string.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.273
diff -u -p -r1.273 string.m
--- library/string.m	26 Jun 2008 03:08:19 -0000	1.273
+++ library/string.m	25 Jul 2008 00:58:52 -0000
@@ -77,6 +77,8 @@
 :- mode string.length(in, uo) is det.
 :- mode string.length(ui, uo) is det.
 
+    % append(Prefix, Suffix, Result)
+    %
     % Append two strings together.
     %
 :- func string.append(string::in, string::in) = (string::uo) is det.
@@ -98,6 +100,15 @@
 :- func string ++ string = string.
 :- mode in ++ in = uo is det.
 
+    % sv_append(Suffix, Prefix, Result)
+    %
+    % Append two strings together,  The arguments of this predicate are ordered
+    % so that they are easier to use with state variables.  For example:
+    %
+    % sv_append(Suffix, !String).
+    %
+:- pred string.sv_append(string::in, string::in, string::uo) is det.
+
     % string.remove_suffix(String, Suffix, Prefix):
     % The same as string.append(Prefix, Suffix, String) except that
     % this is semidet whereas string.append(out, in, in) is nondet.
@@ -4013,6 +4024,9 @@ string.mercury_append(X, Y, Z) :-
     string.to_char_list(Z, ZList),
     list.append(XList, YList, ZList).
 
+string.sv_append(Suffix, Prefix, Result) :-
+    string.append(Prefix, Suffix, Result).
+
 /*-----------------------------------------------------------------------*/
 
 string.substring(Str::in, Start::in, Count::in, SubStr::uo) :-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20080725/514edf61/attachment.sig>


More information about the reviews mailing list