[m-rev.] diff: back out changes to library/int

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Feb 3 15:41:38 AEDT 2005


Estimated hours taken: 0.1
Branches: main, release

Back out the recent change to this module.
It broke far too many test cases.

library/int.m:
	Back out the recent change.

Julien.

Index: int.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.102
diff -u -r1.102 int.m
--- int.m	2 Feb 2005 04:28:46 -0000	1.102
+++ int.m	3 Feb 2005 04:35:04 -0000
@@ -26,38 +26,39 @@

 :- instance enum(int).

-%
-% Comparison.
-%
-
-	% less than, less than or equal, greater than or equal, greater than.
-	%
-:- pred (int::in)  < (int::in) is semidet.
-:- pred (int::in) =< (int::in) is semidet.
-:- pred (int::in) >= (int::in) is semidet.
-:- pred (int::in) >  (int::in) is semidet.
+	% less than
+:- pred int < int.
+:- mode in  < in is semidet.
+
+	% greater than
+:- pred int > int.
+:- mode in  > in is semidet.
+
+	% less than or equal
+:- pred int =< int.
+:- mode in  =< in is semidet.
+
+	% greater than or equal
+:- pred int >= int.
+:- mode in >= in is semidet.

 	% absolute value
-	%
 :- func int__abs(int) = int.
 :- pred int__abs(int, int).
 :- mode int__abs(in, out) is det.

 	% maximum
-	%
 :- func int__max(int, int) = int.
 :- pred int__max(int, int, int).
 :- mode int__max(in, in, out) is det.

 	% minimum
-	%
 :- func int__min(int, int) = int.
 :- pred int__min(int, int, int).
 :- mode int__min(in, in, out) is det.

 	% conversion of integer to floating point
 	% OBSOLETE: use float__float/1 instead.
-	%
 :- pragma obsolete(int.to_float/2).
 :- pred int__to_float(int, float) is det.
 :- mode int__to_float(in, out) is det.
@@ -65,7 +66,6 @@
 	% exponentiation
 	% int__pow(X, Y, Z): Z is X raised to the Yth power
 	% Throws a `math__domain_error' exception if Y is negative.
-	%
 :- func int__pow(int, int) = int.
 :- pred int__pow(int, int, int).
 :- mode int__pow(in, in, out) is det.
@@ -74,32 +74,29 @@
 	% int__log2(X) = N is the least integer such that 2 to the
 	% power N is greater than or equal to X.
 	% Throws a `math__domain_error' exception if X is not positive.
-	%
 :- func int__log2(int) = int.
 :- pred int__log2(int, int).
 :- mode int__log2(in, out) is det.

 	% addition
-	%
 :- func int + int = int.
-:- mode in  + in  = out is det.
-:- mode out + in  = in  is det.
-:- mode in  + out = in  is det.
+:- mode in  + in  = uo  is det.
+:- mode uo  + in  = in  is det.
+:- mode in  + uo  = in  is det.

 :- func int__plus(int, int) = int.

 	% multiplication
-	%
 :- func int * int = int.
+:- mode in  * in  = uo  is det.

 :- func int__times(int, int) = int.

 	% subtraction
-	%
 :- func int - int = int.
-:- mode in  - in  = out is det.
-:- mode out - in  = in  is det.
-:- mode in  - out = in  is det.
+:- mode in  - in  = uo  is det.
+:- mode uo  - in  = in  is det.
+:- mode in  - uo  = in  is det.

 :- func int__minus(int, int) = int.

@@ -109,8 +106,8 @@
 	% Throws a `math__domain_error' exception if the right operand
 	% is zero. See the comments at the top of math.m to find out how to
 	% disable domain checks.
-	%
 :- func div(int, int) = int.
+:- mode div(in, in) = uo is det.

 	% truncating integer division
 	% Truncates towards zero, e.g. (-10) // 3 = (-3).
@@ -120,23 +117,24 @@
 	% Throws a `math__domain_error' exception if the right operand
 	% is zero. See the comments at the top of math.m to find out how to
 	% disable domain checks.
-	%
 :- func int // int = int.
+:- mode in  // in  = uo  is det.

 	% (/)/2 is a synonym for (//)/2 to bring Mercury into line with
 	% the common convention for naming integer division.
 	%
 :- func int / int = int.
+:- mode in  / in  = uo  is det.

 	% unchecked_quotient(X, Y) is the same as X // Y, but the
 	% behaviour is undefined if the right operand is zero.
-	%
 :- func unchecked_quotient(int, int) = int.
+:- mode unchecked_quotient(in, in)  = uo  is det.

 	% modulus
 	% X mod Y = X - (X div Y) * Y
-	%
 :- func int mod int = int.
+:- mode in  mod in  = uo  is det.

 	% remainder
 	% X rem Y = X - (X // Y) * Y
@@ -146,96 +144,93 @@
 	% Throws a `math__domain_error' exception if the right operand
 	% is zero. See the comments at the top of math.m to find out how to
 	% disable domain checks.
-	%
 :- func int rem int = int.
+:- mode in rem in = uo is det.

 	% unchecked_rem(X, Y) is the same as X rem Y, but the
 	% behaviour is undefined if the right operand is zero.
-	%
 :- func unchecked_rem(int, int) = int.
+:- mode unchecked_rem(in, in) = uo is det.

 	% Left shift.
 	% X << Y returns X "left shifted" by Y bits.
 	% To be precise, if Y is negative, the result is
 	% X div (2^(-Y)), otherwise the result is X * (2^Y).
-	%
 :- func int << int = int.
+:- mode in  << in  = uo  is det.

 	% unchecked_left_shift(X, Y) is the same as X << Y
 	% except that the behaviour is undefined if Y is negative,
 	% or greater than or equal to the result of `int__bits_per_int/1'.
 	% It will typically be implemented more efficiently than X << Y.
-	%
 :- func unchecked_left_shift(int, int) = int.
+:- mode unchecked_left_shift(in, in) = uo is det.

 	% Right shift.
 	% X >> Y returns X "arithmetic right shifted" by Y bits.
 	% To be precise, if Y is negative, the result is
 	% X * (2^(-Y)), otherwise the result is X div (2^Y).
-	%
 :- func int >> int = int.
+:- mode in  >> in  = uo  is det.

 	% unchecked_right_shift(X, Y) is the same as X >> Y
 	% except that the behaviour is undefined if Y is negative,
 	% or greater than or equal to the result of `int__bits_per_int/1'.
 	% It will typically be implemented more efficiently than X >> Y.
-	%
 :- func unchecked_right_shift(int, int) = int.
+:- mode unchecked_right_shift(in, in) = uo is det.

 	% even(X) is equivalent to (X mod 2 = 0).
-	%
 :- pred even(int).
 :- mode even(in) is semidet.

 	% odd(X) is equivalent to (not even(X)), i.e. (X mod 2 = 1).
-	%
 :- pred odd(int).
 :- mode odd(in) is semidet.

 	% bitwise and
-	%
 :- func int /\ int = int.
+:- mode in  /\ in  = uo  is det.

 	% bitwise or
-	%
 :- func int \/ int = int.
+:- mode in  \/ in  = uo  is det.

 	% bitwise exclusive or (xor)
-	%
 :- func int__xor(int, int) = int.
+:- mode int__xor(in, in) = uo is det.
+:- mode int__xor(in, uo) = in is det.
+:- mode int__xor(uo, in) = in is det.

 	% bitwise complement
-	%
 :- func \ int = int.
+:- mode \ in  = uo  is det.

 	% unary plus
-	%
 :- func + int = int.
+:- mode + in = uo is det.

 	% unary minus
-	%
 :- func - int = int.
+:- mode - in = uo is det.

 	% is/2, for backwards compatibility with Prolog (and with
-	%
 :- pred is(T, T) is det.
+:- mode is(uo, di) is det.
 :- mode is(out, in) is det.

 	% int__max_int is the maximum value of an int
 	% on this machine.
-	%
 :- func int__max_int = int.
 :- pred int__max_int(int::out) is det.

 	% int__min_int is the minimum value of an int
 	% on this machine.
-	%
 :- func int__min_int = int.
 :- pred int__min_int(int::out) is det.

 	% int__bits_per_int is the number of bits in an int
 	% on this machine.
-	%
 :- func int__bits_per_int = int.
 :- pred int__bits_per_int(int::out) is det.

@@ -356,11 +351,9 @@
 	% here to make sure they go in the `.opt' file.

 	% int__quot_bits_per_int(X) = X // bits_per_int.
-	%
 :- func int__quot_bits_per_int(int) = int.

 	% int__times_bits_per_int(X) = X * bits_per_int.
-	%
 :- func int__times_bits_per_int(int) = int.

 	% Used by bitmap.m.  Like the ones above, the purpose of
@@ -368,7 +361,6 @@
 	% this can be optimized.

 	% int__rem_bits_per_int(X) = X `rem` bits_per_int.
-	%
 :- func int__rem_bits_per_int(int) = int.

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

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