[m-rev.] diff: more stdlib stuff
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue May 10 16:57:00 AEST 2011
Branches: main
library/cord.m:
Add cord.init/0 for consistency with other modules.
library/int.m:
library/char.m:
Group function definitions with the corresponding
predicate definition.
library/version_store.m:
Fix indentation.
NEWS:
Announce the addition of cord.init/0.
Fix some earlier entries.
Julien.
Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.569
diff -u -r1.569 NEWS
--- NEWS 10 May 2011 05:26:51 -0000 1.569
+++ NEWS 10 May 2011 05:37:43 -0000
@@ -62,6 +62,7 @@
array2d.init/3
bitmap.init/2
+ cord.init/0
hash_table.init/3
hash_table.init_default/1
store.init/1
@@ -74,7 +75,7 @@
version_hash_table.unsafe_init/3
version_hash_table.init_default/1
version_hash_table.unsafe_init_default/1
- version_store.init/1
+ version_store.init/0
They replace the following procedures, which are now obsolete and will be
removed in a later release:
@@ -93,7 +94,7 @@
version_hash_table.unsafe_new/3
version_hash_table.new_default/1
version_hash_table.unsafe_new_default/1
- version_store.new/1
+ version_store.new/0
* The following procedures are have been deprecated and will be removed in
a future release: dir.basename_det/1, list.replace_nth_det/3,
Index: library/char.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/char.m,v
retrieving revision 1.62
diff -u -r1.62 char.m
--- library/char.m 4 Apr 2011 07:10:39 -0000 1.62
+++ library/char.m 10 May 2011 05:36:42 -0000
@@ -336,6 +336,9 @@
fail
).
+char.to_lower(C1) = C2 :-
+ char.to_lower(C1, C2).
+
char.to_lower(Char, Lower) :-
( char.lower_upper(LowerChar, Char) ->
Lower = LowerChar
@@ -343,6 +346,9 @@
Lower = Char
).
+char.to_upper(C1) = C2 :-
+ char.to_upper(C1, C2).
+
char.to_upper(Char, Upper) :-
( char.lower_upper(Char, UpperChar) ->
Upper = UpperChar
@@ -426,6 +432,9 @@
%-----------------------------------------------------------------------------%
+char.det_int_to_digit(N) = C :-
+ char.det_int_to_digit(N, C).
+
char.det_int_to_digit(Int, Digit) :-
( char.int_to_digit(Int, Digit1) ->
Digit = Digit1
@@ -529,6 +538,9 @@
Int = (MR_UnsignedChar) Character;
").
+char.to_int(C) = N :-
+ char.to_int(C, N).
+
:- pragma foreign_proc("C",
char.to_int(Character::in, Int::in),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
@@ -612,12 +624,18 @@
SUCCESS_INDICATOR = (Int >= 0 andalso Int =< 16#10ffff)
").
+char.min_char_value = N :-
+ char.min_char_value(N).
+
% We used unsigned character codes, so the minimum character code
% is always zero.
char.min_char_value(0).
:- pragma foreign_decl("C", "#include <limits.h>").
+char.max_char_value = N :-
+ char.max_char_value(N).
+
:- pragma foreign_proc("C",
char.max_char_value(Max::out),
[will_not_call_mercury, promise_pure, thread_safe,
@@ -700,28 +718,8 @@
; Int /\ 0xfffe = 0xfffe
).
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-% Ralph Becket <rwab1 at cl.cam.ac.uk> 27/04/99
-% Functional forms added.
-
-char.to_int(C) = N :-
- char.to_int(C, N).
-
-char.max_char_value = N :-
- char.max_char_value(N).
-
-char.min_char_value = N :-
- char.min_char_value(N).
-
-char.to_upper(C1) = C2 :-
- char.to_upper(C1, C2).
-
-char.to_lower(C1) = C2 :-
- char.to_lower(C1, C2).
-
-char.det_int_to_digit(N) = C :-
- char.det_int_to_digit(N, C).
-
char.char_to_doc(C) = str(term_io.quoted_char(C)).
+%-----------------------------------------------------------------------------%
+:- end_module char.
+%-----------------------------------------------------------------------------%
Index: library/cord.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/cord.m,v
retrieving revision 1.19
diff -u -r1.19 cord.m
--- library/cord.m 10 May 2011 04:12:27 -0000 1.19
+++ library/cord.m 10 May 2011 05:31:45 -0000
@@ -40,6 +40,16 @@
%
:- type cord(T).
+ % Return the empty cord.
+ %
+:- func init = cord(T).
+
+ % The unique representation for the empty cord:
+ %
+ % list(empty) = []
+ %
+:- func empty = cord(T).
+
% The list of data in a cord:
%
% list(empty ) = []
@@ -53,12 +63,6 @@
%
:- func rev_list(cord(T)) = list(T).
- % The unique representation for the empty cord:
- %
- % list(empty) = []
- %
-:- func empty = cord(T).
-
% Succeed iff the given cord is empty.
%
:- pred is_empty(cord(T)::in) is semidet.
@@ -234,6 +238,8 @@
%-----------------------------------------------------------------------------%
+init = empty_cord.
+
empty = empty_cord.
%-----------------------------------------------------------------------------%
Index: library/int.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.127
diff -u -r1.127 int.m
--- library/int.m 13 Dec 2010 04:40:39 -0000 1.127
+++ library/int.m 10 May 2011 05:29:23 -0000
@@ -655,6 +655,9 @@
#define ML_BITS_PER_INT (sizeof(MR_Integer) * CHAR_BIT)
").
+int.max_int = X :-
+ int.max_int(X).
+
:- pragma foreign_proc("C",
int.max_int(Max::out),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
@@ -669,6 +672,9 @@
}
").
+int.min_int = X :-
+ int.min_int(X).
+
:- pragma foreign_proc("C",
int.min_int(Min::out),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
@@ -683,6 +689,9 @@
}
").
+int.bits_per_int = X :-
+ int.bits_per_int(X).
+
:- pragma foreign_proc("C",
int.bits_per_int(Bits::out),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
@@ -794,20 +803,6 @@
Result = Int rem int.bits_per_int.
%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-% Ralph Becket <rwab1 at cl.cam.ac.uk> 27/04/99
-% Functional forms added.
-
-int.max_int = X :-
- int.max_int(X).
-
-int.min_int = X :-
- int.min_int(X).
-
-int.bits_per_int = X :-
- int.bits_per_int(X).
-
-%-----------------------------------------------------------------------------%
int.fold_up(P, Lo, Hi, !A) :-
( if Lo =< Hi
Index: library/version_store.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/version_store.m,v
retrieving revision 1.7
diff -u -r1.7 version_store.m
--- library/version_store.m 8 May 2011 16:02:22 -0000 1.7
+++ library/version_store.m 10 May 2011 05:39:03 -0000
@@ -1,8 +1,9 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2006, 2011 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
-% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
%-----------------------------------------------------------------------------%
%
% File: version_store.m.
@@ -47,20 +48,20 @@
% to the version store.
%
:- pred new_mutvar(T::in, mutvar(T, S)::out,
- version_store(S)::in, version_store(S)::out) is det.
+ version_store(S)::in, version_store(S)::out) is det.
% new_cyclic_mutvar(F, Mutvar, VS0, VS) adds a new mutvar with value
% reference F(Mutvar) to the version store. This can be used to
% construct cyclic terms.
%
:- pred new_cyclic_mutvar((func(mutvar(T, S)) = T)::in, mutvar(T, S)::out,
- version_store(S)::in, version_store(S)::out) is det.
+ version_store(S)::in, version_store(S)::out) is det.
% copy_mutvar(Mutvar, NewMutvar, VS0, VS) constructs NewMutvar
% with the same value reference as Mutvar.
%
:- pred copy_mutvar(mutvar(T, S)::in, mutvar(T, S)::out,
- version_store(S)::in, version_store(S)::out) is det.
+ version_store(S)::in, version_store(S)::out) is det.
% VS ^ elem(Mutvar) returns the element referenced by Mutvar in
% the version store.
@@ -72,8 +73,8 @@
% A predicate version is also provided.
%
:- func lookup(version_store(S), mutvar(T, S)) = T.
-:- pred get_mutvar(mutvar(T, S)::in, T::out, version_store(S)::in,
- version_store(S)::out) is det.
+:- pred get_mutvar(mutvar(T, S)::in, T::out,
+ version_store(S)::in, version_store(S)::out) is det.
% ( VS ^ elem(Mutvar) := X ) updates the version store so that
% Mutvar now refers to value X.
@@ -85,8 +86,8 @@
% A predicate version is also provided.
%
:- func set(version_store(S), mutvar(T, S), T) = version_store(S).
-:- pred set_mutvar(mutvar(T, S)::in, T::in, version_store(S)::in,
- version_store(S)::out) is det.
+:- pred set_mutvar(mutvar(T, S)::in, T::in,
+ version_store(S)::in, version_store(S)::out) is det.
% unsafe_rewind(VS) produces a version of VS for which all accesses are
% O(1). Invoking this predicate renders undefined VS and all later
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list