[m-rev.] for review: delete or deprecate obsolete builtin insts, modes and predicates
Julien Fischer
jfischer at opturion.com
Tue Dec 1 17:51:51 AEDT 2015
For review by anyone.
This has been discussed on the developers list, the main thing for review
is the documentation changes.
------------------
Delete or deprecate obsolete builtin insts, modes and predicates.
Update the list of changes in the NEWS file that potentially break backwards
compatibility.
library/builtins.m:
Delete the builtin inst synonyms 'old' and 'new'.
Delete the builtin builtin modes 'oo' and 'no'.
Add a comment stating that the modes input/0 and output/0 are deprecated.
Add obsolete pragmas for promise_only_solution/1 and
promise_only_solution_io/4.
Shift the description of the 'any' inst into the comment describing
the other builtin insts. Add the higher-order 'any' insts to this
comment.
Fix a typo in the description of the builtin higher-order insts: the
determinism is not required to be det.
browser/term_rep.m:
Replace calls to promise_only_solutions/1 with promise_equivalent_solutions
goals.
browser/trace_counts.m:
Replace a call to promise_only_solution_io/4 with a
promise_equivalent_solutions goal.
Add an XXX comment about hardcoding executable names.
NEWS:
Announce the deletion of 'old', 'new', '
List the addition of the 'for' operator as a change that may break
backwards compatibility.
Announce that the compiler no longer allows builtin types, insts and
modes to be redefined.
Julien.
diff --git a/NEWS b/NEWS
index 8e5161a..b77d262 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,60 @@ Changes that may break compatibility:
exported from that module. This may require the explicit export of e.g.
some types that previously were not exported.
+* `for' is now an operator.
+
+* It is now an error for a program to redefine a builtin type. The affected
+ type names are:
+
+ int
+ float
+ character
+ string
+ {}
+ =
+ pred
+ func
+ pure
+ semipure
+ impure
+ ''
+
+* It is now an error for a program to redefine a builtin inst. The affected
+ inst names are:
+
+ =<
+ any
+ bound
+ bound_unique
+ clobbered
+ clobbered_any
+ free
+ ground
+ is
+ mostly_clobbered
+ mostly_unique
+ mostly_unique_any
+ not_reached
+ unique
+ unique_any
+
+* It is now an error for a program to redefine a builtin mode. The affected
+ mode names are:
+
+ =
+ >>
+ any_func
+ any_pred
+ func
+ is
+ pred
+
+* We have deleted the builtin inst synonyms `old' and `new': their use
+ should be replaced with `any' and `free' respectively.
+
+* We have delete the builtin modes `no' and `oo': their use should be
+ replaced with `oa' and `ia' respectively.
+
Changes to the Mercury language:
* We have added a new kind of scope to the language: determinism checks
@@ -41,8 +95,6 @@ Changes to the Mercury language:
of the foreign type when the type appears as the sole argument of a data
constructor.
-* `for' is now an operator.
-
Changes to the Mercury standard library:
* We have added variants of the process_options predicates to the getopt
@@ -199,6 +251,24 @@ Changes to the Mercury standard library:
- reverse_prepend/2
- reverse_prepend/3
+* The following predicate and function in the builtin module have been
+ deprecated and will be removed in a future release:
+
+ - promise_only_solution/1
+ - promise_only_solution_io/4
+
+ Existing code that uses either of these should be replaced with code that
+ uses a `promise_equivalent_solutions' goal instead.
+
+* The following modes in the builtin module have been deprecated and will
+ be removed in a future release:
+
+ - input/0
+ - output/0
+
+ Existing code that uses these modes should replace their use with `in'
+ or `out' respectively.
+
Changes to the Mercury compiler:
* We have fixed a long-standing bug causing crashes in deep profiling
diff --git a/browser/term_rep.m b/browser/term_rep.m
index b1578aa..873ecfc 100644
--- a/browser/term_rep.m
+++ b/browser/term_rep.m
@@ -77,7 +77,10 @@
:- pragma terminates(term_rep_equal/2).
term_rep_equal(Rep1, Rep2) :-
- (=) = promise_only_solution(comp_rep_2(Rep1, Rep2)).
+ promise_equivalent_solutions [Result] (
+ comp_rep_2(Rep1, Rep2, Result)
+ ),
+ Result = (=).
:- pred comp_rep_2(term_rep::in, term_rep::in, builtin.comparison_result::uo)
is cc_multi.
@@ -90,13 +93,16 @@ comp_rep_2(Rep1, Rep2, Result) :-
:- pragma terminates(term_rep_compare/3).
term_rep_compare(Result, Rep1, Rep2) :-
- Result = promise_only_solution(comp_rep_2(Rep1, Rep2)).
+ promise_equivalent_solutions [Result] (
+ comp_rep_2(Rep1, Rep2, Result)
+ ).
-univ_to_rep(Univ0, term_rep(Univ)) :- cc_multi_equal(Univ0, Univ).
+univ_to_rep(Univ0, term_rep(Univ)) :-
+ cc_multi_equal(Univ0, Univ).
rep_to_univ(Rep, Univ) :-
- Univ = promise_only_solution(
- pred(U::out) is cc_multi :- Rep = term_rep(U)
+ promise_equivalent_solutions [Univ] (
+ Rep = term_rep(Univ)
).
deref_path(Term, Path, SubTerm):-
diff --git a/library/builtin.m b/library/builtin.m
index e5c013c..65312f9 100644
--- a/library/builtin.m
+++ b/library/builtin.m
@@ -42,40 +42,42 @@
%---------------------------------------------------------------------------%
%
-% Insts
+% Insts.
%
-% The standard insts `free', `ground', and `bound(...)' are builtin
-% and are implemented using special code in the parser and mode-checker.
+% The standard insts `free', `ground', and `bound(...)' are builtin and are
+% implemented using special code in the parser and mode-checker.
%
-% So are the standard unique insts `unique', `unique(...)',
-% `mostly_unique', `mostly_unique(...)', and `clobbered'.
+% So are the standard unique insts `unique', `unique(...)', `mostly_unique',
+% `mostly_unique(...)', and `clobbered'.
%
% Higher-order predicate insts `pred(<modes>) is <detism>'
-% and higher-order functions insts `func(<modes>) = <mode> is det'
+% and higher-order function insts `func(<modes>) = <mode> is <detism>'
% are also builtin.
+%
+% The `any' inst used for constraint solver interfaces is builtin and so are
+% its higher-order variants: `any_pred(<modes>) is <detism>' and
+% `any_func(<modes>) = <mode> is <detism>'.
% The name `dead' is allowed as a synonym for `clobbered'.
- % Similarly `mostly_dead' is a synonym for `mostly_clobbered'.
+ % Similarly, `mostly_dead' is a synonym for `mostly_clobbered'.
%
:- inst dead == clobbered.
:- inst mostly_dead == mostly_clobbered.
- % The `any' inst used for the constraint solver interface is also
- % builtin. The insts `new' and `old' are allowed as synonyms for
- % `free' and `any', respectively, since some of the literature uses
- % this terminology.
- %
-:- inst old == any.
-:- inst new == free.
-
%---------------------------------------------------------------------------%
%
-% Standard modes
+% Standard modes.
%
:- mode unused == free >> free.
+
+ % This mode is deprecated, use `out' instead.
+ %
:- mode output == free >> ground.
+
+ % This mode is deprecated, use `in' instead.
+ %
:- mode input == ground >> ground.
:- mode in == ground >> ground.
@@ -88,7 +90,7 @@
%---------------------------------------------------------------------------%
%
-% Unique modes
+% Unique modes.
%
% XXX These are still not fully implemented.
@@ -107,7 +109,7 @@
%---------------------------------------------------------------------------%
%
-% "Mostly" unique modes
+% "Mostly" unique modes.
%
% Unique except that they may be referenced again on backtracking.
@@ -126,7 +128,7 @@
%---------------------------------------------------------------------------%
%
-% Dynamic modes
+% Dynamic modes.
%
% Solver type modes.
@@ -134,15 +136,9 @@
:- mode ia == any >> any.
:- mode oa == free >> any.
- % The modes `no' and `oo' are allowed as synonyms, since some of the
- % literature uses this terminology.
- %
-:- mode no == new >> old.
-:- mode oo == old >> old.
-
%---------------------------------------------------------------------------%
%
-% Predicates
+% Predicates.
%
% copy/2 makes a deep copy of a data structure.
@@ -201,9 +197,10 @@
% assumption is not satisfied, the behaviour is undefined. (If you lie
% to the compiler, the compiler will get its revenge!)
%
- % NOTE: we recommend using the a `promise_equivalent_solutions' goal
- % instead of this function.
+ % NOTE: This function is deprecated and will be removed in a future
+ % release. Use a `promise_equivalent_solutions' goal instead.
%
+:- pragma obsolete(promise_only_solution/1).
:- func promise_only_solution(pred(T)) = T.
:- mode promise_only_solution(pred(out) is cc_multi) = out is det.
:- mode promise_only_solution(pred(uo) is cc_multi) = uo is det.
@@ -224,9 +221,10 @@
% the assumption is not satisfied, the behaviour is undefined. (If you
% lie to the compiler, the compiler will get its revenge!)
%
- % NOTE: we recommend using a `promise_equivalent_solutions' goal
- % instead of this predicate.
+ % NOTE: This predicate is deprecated and will be removed in a future
+ % release. Use a `promise_equivalent_solutions' goal instead.
%
+:- pragma obsolete(promise_only_solution_io/4).
:- pred promise_only_solution_io(
pred(T, IO, IO)::in(pred(out, di, uo) is cc_multi), T::out,
IO::di, IO::uo) is det.
diff --git a/mdbcomp/trace_counts.m b/mdbcomp/trace_counts.m
index 8f13ffd..e9a945f 100644
--- a/mdbcomp/trace_counts.m
+++ b/mdbcomp/trace_counts.m
@@ -393,6 +393,8 @@ read_trace_counts(FileName, ReadResult, !IO) :-
% and having to recreate it again. Unfortunately, we don't have any
% facilities equivalent to popen in Unix, and I don't know how to
% write one in a way that is portable to Windows. zs.
+ % XXX ... and we certainly shouldn't be hardcoding the names of the
+ % gzip / gunzip executables. juliensf.
( if string.remove_suffix(FileName, ".gz", BaseName) then
io.call_system("gunzip " ++ FileName, _UnzipResult, !IO),
ActualFileName = BaseName,
@@ -410,8 +412,9 @@ read_trace_counts(FileName, ReadResult, !IO) :-
IdReadResult = ok(FirstLine),
string.rstrip(FirstLine) = trace_count_file_id
then
- promise_only_solution_io(read_trace_counts_from_cur_stream,
- ReadResult, !IO)
+ promise_equivalent_solutions [ReadResult, !:IO] (
+ read_trace_counts_from_cur_stream(ReadResult, !IO)
+ )
else
ReadResult = syntax_error("no trace count file id")
),
More information about the reviews
mailing list