[m-rev.] diff: misc. small cleanups in library

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Oct 11 18:32:20 AEST 2004


Estimated hours taken: 0.5
Branches: main

Make a number of small changes to purity declarations, remove
some redundant foreign proc attributes and delete some long
obsolete predicates.

library/float.m:
	Attach purity annotations directly to foreign procs
	for float.is_nan/1 and float.is_inf/1.  Delete the
	separate pragma promise_pure declaration.

	Remove max_stack_size attributes from Java foreign
	procs - they are only meaningful for IL foreign procs.

library/string.m:
	Shift the pragma promise_pure declaration for
	string.to_char_list/2 so that is directly above the
	Mercury clauses for this predicate.  In its present
	position it looks redundant because it's directly above
	the foreign clauses for the same predicate and these
	already have purity annotations.

library/term.m:
	Delete the predicate term.compare/4.  It has been marked
	as obsolete since version 0.8.

library/term_io.m:
	Delete the predicate term_io.quote_single_char/3.  It has
	been marked as obsolete since version 0.7.

Julien.

Index: library/float.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/float.m,v
retrieving revision 1.60
diff -u -r1.60 float.m
--- library/float.m	8 Jul 2004 05:56:36 -0000	1.60
+++ library/float.m	11 Oct 2004 08:05:59 -0000
@@ -539,16 +539,15 @@
 	; is_inf(Float)
 	).

-:- pragma promise_pure(is_nan/1).
 :- pragma foreign_proc(c,
 	is_nan(Flt::in),
-	[will_not_call_mercury, thread_safe],
+	[will_not_call_mercury, promise_pure, thread_safe],
 "
 	SUCCESS_INDICATOR = MR_is_nan(Flt);
 ").
 :- pragma foreign_proc(il,
 	is_nan(Flt::in),
-	[will_not_call_mercury, thread_safe, max_stack_size(1)],
+	[will_not_call_mercury, promise_pure, thread_safe, max_stack_size(1)],
 "
 	ldloc 'Flt'
 	call bool [mscorlib]System.Double::IsNaN(float64)
@@ -556,21 +555,20 @@
 ").
 :- pragma foreign_proc("Java",
 	is_nan(Flt::in),
-	[will_not_call_mercury, thread_safe, max_stack_size(1)],
+	[will_not_call_mercury, promise_pure, thread_safe],
 "
 	succeeded = java.lang.Double.isNaN(Flt);
 ").

-:- pragma promise_pure(is_inf/1).
 :- pragma foreign_proc(c,
 	is_inf(Flt::in),
-	[will_not_call_mercury, thread_safe],
+	[will_not_call_mercury, promise_pure, thread_safe],
 "
 	SUCCESS_INDICATOR = MR_is_inf(Flt);
 ").
 :- pragma foreign_proc(il,
 	is_inf(Flt::in),
-	[will_not_call_mercury, thread_safe, max_stack_size(1)],
+	[will_not_call_mercury, promise_pure, thread_safe, max_stack_size(1)],
 "
 	ldloc 'Flt'
 	call bool [mscorlib]System.Double::IsInfinity(float64)
@@ -578,7 +576,7 @@
 ").
 :- pragma foreign_proc("Java",
 	is_inf(Flt::in),
-	[will_not_call_mercury, thread_safe, max_stack_size(1)],
+	[will_not_call_mercury, promise_pure, thread_safe],
 "
 	succeeded = java.lang.Double.isInfinite(Flt);
 ").
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.219
diff -u -r1.219 string.m
--- library/string.m	5 Oct 2004 05:48:59 -0000	1.219
+++ library/string.m	5 Oct 2004 12:17:34 -0000
@@ -886,7 +886,6 @@
 % :- mode string__to_char_list(in, uo) is det.
 % :- mode string__to_char_list(uo, in) is det.

-:- pragma promise_pure(string__to_char_list/2).
 :- pragma foreign_proc("C",
 	string__to_char_list(Str::in, CharList::out),
 	[will_not_call_mercury, promise_pure, thread_safe],
@@ -940,6 +939,7 @@
 	Str[size] = '\\0';
 }").

+:- pragma promise_pure(string__to_char_list/2).
 string__to_char_list(Str::in, CharList::out) :-
 	string__to_char_list_2(Str, 0, CharList).
 string__to_char_list(Str::uo, CharList::in) :-
Index: library/term.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/term.m,v
retrieving revision 1.106
diff -u -r1.106 term.m
--- library/term.m	8 Jul 2004 05:56:37 -0000	1.106
+++ library/term.m	11 Oct 2004 08:06:00 -0000
@@ -377,19 +377,6 @@
 :- pred term__term_to_type_with_int_instead_of_char(term(U)::in, T::out)
 	is semidet.

-	% term__compare(Comparison, Term1, Term2, Bindings) is true iff
-	% there is a binding of Comparison to <, =, or > such
-	% that the binding holds for the two ground terms Term1
-	% and Term2 with respect to the bindings in Bindings.
-	% Fails if Term1 or Term2 is not ground (with respect to
-	% the bindings in Bindings).
-	%
-	% BEWARE: This predicate is being phased out, because the comparison
-	% does *not* ignore the term__contexts in the terms.
-:- pragma obsolete(term__compare/4).
-:- pred term__compare(comparison_result::out, term(T)::in, term(T)::in,
-	substitution(T)::in) is semidet.
-
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

@@ -1086,15 +1073,6 @@
 term__is_ground_2([Term | Terms]) :-
 	term__is_ground(Term),
 	term__is_ground_2(Terms).
-
-%-----------------------------------------------------------------------------%
-
-term__compare(Cmp, Term1, Term2, Bindings) :-
-	term__apply_rec_substitution(Term1, Bindings, TermA),
-	term__is_ground(TermA, Bindings),
-	term__apply_rec_substitution(Term2, Bindings, TermB),
-	term__is_ground(TermB, Bindings),
-	compare(Cmp, TermA, TermB).

 %-----------------------------------------------------------------------------%

Index: library/term_io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/term_io.m,v
retrieving revision 1.69
diff -u -r1.69 term_io.m
--- library/term_io.m	18 Mar 2004 03:51:02 -0000	1.69
+++ library/term_io.m	11 Oct 2004 08:06:03 -0000
@@ -117,11 +117,6 @@
 	% Like term_io__write_escaped_char, but return the result in a string.
 :- func term_io__escaped_string(string) = string.

-	% `term_io__quote_single_char' is the old (misleading) name for
-	% `term_io__write_escaped_char'. Use the latter instead.
-:- pragma obsolete(term_io__quote_single_char/3).
-:- pred term_io__quote_single_char(char::in, io::di, io::uo) is det.
-
 %-----------------------------------------------------------------------------%

 :- implementation.
@@ -585,9 +580,6 @@

 term_io__add_escaped_char(Char, String0) = String :-
 	String = string__append(String0, string__char_to_string(Char)).
-
-term_io__quote_single_char(Char, !IO) :-
-	term_io__write_escaped_char(Char, !IO).

 	% Note: the code here is similar to code in
 	% compiler/mercury_to_mercury.m; any changes here

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