[m-rev.] diff: array module changes
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Jan 12 15:49:21 AEDT 2012
The changes to the header comments in array.m were discussed in-person
in the office yesterday. If we do want to provide a mechanism
for globally disabling bounds checks it was agreed that doing this
using trace goals would be a better solution than defining
ML_OMIT_ARRAY_BOUNDS_CHECKS.
Branches: main, 11.07 (documentation fix for array.bsearch/4 only)
Changes to array module.
library/array.m:
Omit the header comment regarding the use of
ML_OMIT_ARRAY_BOUNDS_CHECKS. Beside being specific to the
C backends, requiring users to recompile the library (or
parts thereof) is just awkward. In any case, the array
module now exports "unsafe" versions of the relevant
operations that omit the bounds checking, so the old
approach should be unnecessary.
Mark array.svset/4 and array.unsafe_svset/4 as obsolete.
They will be deleted after the next release.
Fix the documentation of array.bsearch/4. It does _not_
fail if the element being searched for is not present.
mdbcomp/mdbcomp.goal_path.m:
Conform to the above change.
compiler/llds_out_data.m:
Fix some formatting.
Julien.
Index: compiler/llds_out_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out_data.m,v
retrieving revision 1.8
diff -u -r1.8 llds_out_data.m
--- compiler/llds_out_data.m 20 Oct 2011 03:35:56 -0000 1.8
+++ compiler/llds_out_data.m 11 Jan 2012 08:16:38 -0000
@@ -710,7 +710,7 @@
true
;
decl_set_insert(FloatLabel, !DeclSet),
- FloatString = c_util.make_float_literal( FloatVal),
+ FloatString = c_util.make_float_literal(FloatVal),
output_indent(FirstIndent, LaterIndent, !.N, !IO),
!:N = !.N + 1,
io.write_strings(["static const MR_Float ",
Index: library/array.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.192
diff -u -r1.192 array.m
--- library/array.m 13 Aug 2011 16:19:52 -0000 1.192
+++ library/array.m 12 Jan 2012 04:33:35 -0000
@@ -13,22 +13,6 @@
% This module provides dynamically-sized one-dimensional arrays.
% Array indices start at zero.
%
-% By default, the array.set and array.lookup procedures will check
-% for bounds errors. But for better performance, it is possible to
-% disable some of the checking by compiling with `--intermodule-optimization'
-% and with the C macro symbol `ML_OMIT_ARRAY_BOUNDS_CHECKS'
-% defined, e.g. by using `MCFLAGS=--intermodule-optimization' and
-% `CFLAGS=-DML_OMIT_ARRAY_BOUNDS_CHECKS' in your Mmakefile,
-% or by compiling with the command
-% `mmc --intermodule-optimization --cflags -DML_OMIT_ARRAY_BOUNDS_CHECKS'.
-%
-% For maximum performance, all bounds checking can be disabled by
-% recompiling this module using `CFLAGS=-DML_OMIT_ARRAY_BOUNDS_CHECKS'
-% or `mmc --cflags -DML_OMIT_ARRAY_BOUNDS_CHECKS' as above. You can
-% either recompile the entire library, or just copy `array.m' to your
-% application's source directory and link with it directly instead of as
-% part of the library.
-%
% WARNING!
%
% Arrays are currently not unique objects. until this situation is resolved,
@@ -239,15 +223,15 @@
:- pred array.set(int, T, array(T), array(T)).
:- mode array.set(in, in, array_di, array_uo) is det.
- % The same as array.set, except the arguments are in an order
- % that allows the use of state variables.
+:- func array.set(array(T), int, T) = array(T).
+:- mode array.set(array_di, in, in) = array_uo is det.
+
+ % An obsolete synonym for array.set/4.
%
+:- pragma obsolete(array.svset/4).
:- pred array.svset(int, T, array(T), array(T)).
:- mode array.svset(in, in, array_di, array_uo) is det.
-:- func array.set(array(T), int, T) = array(T).
-:- mode array.set(array_di, in, in) = array_uo is det.
-
% array.semidet_set sets the nth element of an array, and returns
% the resulting array. It fails if the index is out of bounds.
%
@@ -260,9 +244,9 @@
:- pred array.unsafe_set(int, T, array(T), array(T)).
:- mode array.unsafe_set(in, in, array_di, array_uo) is det.
- % The same as array.unsafe_set, except the arguments are in an order
- % that allows the use of state variables.
+ % An obsolete synonym for array.unsafe_set/4.
%
+:- pragma obsolete(array.unsafe_svset/4).
:- pred array.unsafe_svset(int, T, array(T), array(T)).
:- mode array.unsafe_svset(in, in, array_di, array_uo) is det.
@@ -389,7 +373,6 @@
% predicate and returns the position of the first occurrence in the array
% of an element which is equivalent to the given one in the ordering
% provided. Assumes the array is sorted according to this ordering.
- % Fails if the element is not present.
%
:- pred array.bsearch(array(T), T, comparison_pred(T), maybe(int)).
%:- mode array.bsearch(array_ui, in, in(comparison_pred), out) is det.
@@ -2876,15 +2859,15 @@
compare(R, X1, X2),
(
R = (<),
- array.svset(I, X1, !B),
+ array.set(I, X1, !B),
merge_subarrays(A, Lo1 + 1, Hi1, Lo2, Hi2, I + 1, !B)
;
R = (=),
- array.svset(I, X1, !B),
+ array.set(I, X1, !B),
merge_subarrays(A, Lo1 + 1, Hi1, Lo2, Hi2, I + 1, !B)
;
R = (>),
- array.svset(I, X2, !B),
+ array.set(I, X2, !B),
merge_subarrays(A, Lo1, Hi1, Lo2 + 1, Hi2, I + 1, !B)
)
).
Index: mdbcomp/mdbcomp.goal_path.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/mdbcomp.goal_path.m,v
retrieving revision 1.8
diff -u -r1.8 mdbcomp.goal_path.m
--- mdbcomp/mdbcomp.goal_path.m 27 Sep 2011 00:49:27 -0000 1.8
+++ mdbcomp/mdbcomp.goal_path.m 12 Jan 2012 04:35:39 -0000
@@ -656,7 +656,7 @@
update_goal_attribute(goal_id(Index), Value, goal_attr_array(!.Array),
goal_attr_array(!:Array)) :-
- array.svset(Index, yes(Value), !Array).
+ array.set(Index, yes(Value), !Array).
get_goal_attribute_det(goal_attr_array(Array), goal_id(Index)) = Attr :-
MaybeAttr = array.lookup(Array, Index),
--------------------------------------------------------------------------
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