[m-rev.] for review: deprecate old-style lambda expressions properly
Julien Fischer
juliensf at cs.mu.OZ.AU
Sun Jul 11 01:26:03 AEST 2004
Estimated hours taken: 3
Branches: main
Deprecate old-style lambda expressions properly.
compiler/make_hlds.m:
Emit a warning if an old-style lambda expression is
encountered.
compiler/notes/todo.html:
Remove this from the TODO list.
compiler/base_typeclass_info.m:
compiler/mercury_to_mercury.m:
extras/odbc/odbc.m:
tests/*/*.m:
Replace old-style lambda expressions as necessary.
Julien.
Index: compiler/base_typeclass_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.29
diff -u -r1.29 base_typeclass_info.m
--- compiler/base_typeclass_info.m 14 Jun 2004 04:15:56 -0000 1.29
+++ compiler/base_typeclass_info.m 9 Jul 2004 07:31:19 -0000
@@ -118,7 +118,7 @@
list__length(Constraints, NumConstraints),
list__length(Unconstrained, NumUnconstrained),
NumExtra = NumConstraints + NumUnconstrained,
- ExtractPredProcId = lambda([HldsPredProc::in, PredProc::out] is det,
+ ExtractPredProcId = (pred(HldsPredProc::in, PredProc::out) is det :-
(
HldsPredProc = hlds_class_proc(PredId, ProcId),
PredProc = proc(PredId, ProcId)
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.473
diff -u -r1.473 make_hlds.m
--- compiler/make_hlds.m 16 Jun 2004 03:44:46 -0000 1.473
+++ compiler/make_hlds.m 9 Jul 2004 06:46:17 -0000
@@ -7497,6 +7497,11 @@
parse_lambda_expression(LambdaExpressionTerm,
Vars0, Modes0, Det0)
->
+ report_warning(Context, 0,
+ [words("Warning: deprecated lambda expression syntax."), nl,
+ words("Lambda expressions with lambda as the top-level functor"),
+ words("are deprecated; please use the form using pred instead.")],
+ !IO),
LambdaPurity = (pure),
PredOrFunc = predicate,
EvalMethod = EvalMethod0,
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.244
diff -u -r1.244 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m 28 Jun 2004 04:49:42 -0000 1.244
+++ compiler/mercury_to_mercury.m 9 Jul 2004 19:50:15 -0000
@@ -688,11 +688,9 @@
mercury_output_sym_name(ClassName),
io__write_char('('),
io__write_list(Vars, ", ",
- lambda([V::in, IO0::di, IO::uo] is det,
- (
+ (pred(V::in, IO0::di, IO::uo) is det :-
varset__lookup_name(VarSet, V, VarName),
io__write_string(VarName, IO0, IO)
- )
)
),
io__write_char(')'),
Index: compiler/notes/todo.html
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/notes/todo.html,v
retrieving revision 1.15
diff -u -r1.15 todo.html
--- compiler/notes/todo.html 30 Jan 2003 05:59:23 -0000 1.15
+++ compiler/notes/todo.html 9 Jul 2004 07:39:54 -0000
@@ -20,15 +20,6 @@
<p>
-<h2> syntax </h2>
-
-<p>
-
-<ul>
-<li> Warn about the use of the deprecated old-style lambda expressions.
-
-</ul>
-
<h2> type system </h2>
<p>
Index: extras/odbc/odbc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/odbc/odbc.m,v
retrieving revision 1.16
diff -u -r1.16 odbc.m
--- extras/odbc/odbc.m 5 Jul 2004 04:39:00 -0000 1.16
+++ extras/odbc/odbc.m 9 Jul 2004 07:36:25 -0000
@@ -1969,10 +1969,10 @@
{ list__reverse(RevDescs, Descs) },
{ assoc_list__from_corresponding_lists(SourceNames,
Descs, SourceAL) },
- { MakeSource = lambda([Pair::in, SourceDesc::out] is det, (
+ { MakeSource = (pred(Pair::in, SourceDesc::out) is det :-
Pair = SourceName - Desc,
SourceDesc = odbc__source_desc(SourceName, Desc)
- )) },
+ ) },
{ list__map(MakeSource, SourceAL, Sources) },
{ MaybeSources = ok(Sources) }
; { odbc__no_data(Status) } ->
@@ -2101,13 +2101,13 @@
odbc__convert_table_desc(Row0, Table) :-
NullToEmptyStr =
- lambda([Data0::in, Data::out] is det, (
+ (pred(Data0::in, Data::out) is det :-
( Data0 = null ->
Data = string("")
;
Data = Data0
)
- )),
+ ),
list__map(NullToEmptyStr, Row0, Row),
Row = [string(Qualifier), string(Owner), string(Name),
string(Type), string(Description) | DriverColumns],
Index: tests/general/array_test.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/array_test.m,v
retrieving revision 1.4
diff -u -r1.4 array_test.m
--- tests/general/array_test.m 24 Apr 2001 03:59:13 -0000 1.4
+++ tests/general/array_test.m 9 Jul 2004 07:06:32 -0000
@@ -18,7 +18,7 @@
test(Xs) -->
{
- Cmp = lambda([X :: in, Y :: in, Res :: out] is det,
+ Cmp = (pred(X :: in, Y :: in, Res :: out) is det :-
compare(Res, X, Y)),
array__from_list(Xs, A0)
},
Index: tests/general/disj_disj.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/disj_disj.m,v
retrieving revision 1.5
diff -u -r1.5 disj_disj.m
--- tests/general/disj_disj.m 20 May 1997 02:06:41 -0000 1.5
+++ tests/general/disj_disj.m 9 Jul 2004 07:07:17 -0000
@@ -11,8 +11,8 @@
:- import_module std_util, list.
main -->
- { solutions(lambda([Pair::out] is multi,
- (Pair = X-Y, q(X, Y))), List) },
+ { solutions((pred(Pair::out) is multi :-
+ Pair = X-Y, q(X, Y)), List) },
print_list(List).
:- pred print_list(list(pair(int))::in, io__state::di, io__state::uo) is det.
Index: tests/general/dnf.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/dnf.m,v
retrieving revision 1.2
diff -u -r1.2 dnf.m
--- tests/general/dnf.m 20 May 1997 02:06:42 -0000 1.2
+++ tests/general/dnf.m 9 Jul 2004 07:07:47 -0000
@@ -12,8 +12,8 @@
:- import_module std_util, list.
main -->
- { solutions(lambda([Pair::out] is multi,
- (Pair = X-Y, q(X, Y))), List) },
+ { solutions((pred(Pair::out) is multi :-
+ Pair = X-Y, q(X, Y)), List) },
print_list(List).
:- pred print_list(list(pair(int))::in, io__state::di, io__state::uo) is det.
Index: tests/general/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/higher_order.m,v
retrieving revision 1.2
diff -u -r1.2 higher_order.m
--- tests/general/higher_order.m 20 May 1997 02:06:43 -0000 1.2
+++ tests/general/higher_order.m 9 Jul 2004 07:09:07 -0000
@@ -30,7 +30,7 @@
io__write_strings(List),
io__write_string("\n"),
(
- { higher_order__map(lambda([X::in, Y::in] is semidet,
+ { higher_order__map((pred(X::in, Y::in) is semidet :-
double(X, Y)), ["ab"], ["abab"]) }
->
io__write_string("Yes\n")
@@ -38,7 +38,7 @@
io__write_string("Oops\n")
),
(
- { higher_order__map(lambda([X::in, Y::in] is semidet,
+ { higher_order__map((pred(X::in, Y::in) is semidet :-
double(X, Y)), ["ab"], ["abracadabra"]) }
->
io__write_string("Oops\n")
@@ -46,7 +46,7 @@
io__write_string("No\n")
),
(
- { higher_order__map(lambda([X::in, Y::in] is semidet,
+ { higher_order__map((pred(X::in, Y::in) is semidet :-
double(X, Y)), ["ab"], []) }
->
io__write_string("Oops\n")
Index: tests/general/mode_inf.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/mode_inf.m,v
retrieving revision 1.3
diff -u -r1.3 mode_inf.m
--- tests/general/mode_inf.m 26 May 2003 09:00:59 -0000 1.3
+++ tests/general/mode_inf.m 9 Jul 2004 07:09:29 -0000
@@ -9,7 +9,7 @@
:- use_module array.
main -->
- { solutions(lambda([X::out] is multi, do_some_stuff(X)), L) },
+ { solutions((pred(X::out) is multi :- do_some_stuff(X)), L) },
io__write_list(L, "\n", io__write), io__nl.
do_some_stuff(X) :-
Index: tests/general/nondet_disj.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/nondet_disj.m,v
retrieving revision 1.5
diff -u -r1.5 nondet_disj.m
--- tests/general/nondet_disj.m 20 May 1997 02:06:44 -0000 1.5
+++ tests/general/nondet_disj.m 9 Jul 2004 07:09:55 -0000
@@ -10,8 +10,8 @@
:- import_module std_util, list.
main -->
- { solutions(lambda([Pair::out] is multi,
- (Pair = X-Y, q(X, Y))), List) },
+ { solutions((pred(Pair::out) is multi :-
+ Pair = X-Y, q(X, Y)), List) },
print_list(List).
:- pred print_list(list(pair(int))::in, io__state::di, io__state::uo) is det.
Index: tests/general/parse_list.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/parse_list.m,v
retrieving revision 1.3
diff -u -r1.3 parse_list.m
--- tests/general/parse_list.m 28 May 1998 14:29:45 -0000 1.3
+++ tests/general/parse_list.m 9 Jul 2004 07:10:17 -0000
@@ -17,7 +17,7 @@
:- import_module builtin, int, string.
main -->
- {P = lambda([I::in, O::out, N::out] is semidet, one_or_two(N, I, O))},
+ {P = (pred(I::in, O::out, N::out) is semidet :- one_or_two(N, I, O))},
( {meta_parse_list(P, [X, Y], [2, 1, 3], _)} ->
{string__int_to_string(X, SX)},
{string__int_to_string(Y, SY)},
Index: tests/general/semidet_lambda.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/semidet_lambda.m,v
retrieving revision 1.2
diff -u -r1.2 semidet_lambda.m
--- tests/general/semidet_lambda.m 4 Nov 1996 07:08:39 -0000 1.2
+++ tests/general/semidet_lambda.m 9 Jul 2004 07:10:44 -0000
@@ -25,5 +25,5 @@
:- pred q(list(int)::out) is det.
q(Y) :-
- solutions(lambda([X::out] is nondet,p(X)), Y).
+ solutions((pred(X::out) is nondet :- p(X)), Y).
Index: tests/hard_coded/checked_nondet_tailcall.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/checked_nondet_tailcall.m,v
retrieving revision 1.1
diff -u -r1.1 checked_nondet_tailcall.m
--- tests/hard_coded/checked_nondet_tailcall.m 30 Sep 1999 08:55:51 -0000 1.1
+++ tests/hard_coded/checked_nondet_tailcall.m 9 Jul 2004 07:00:36 -0000
@@ -56,7 +56,7 @@
:- pred join(int::in, list(int)::out) is det.
join(A, Bs) :-
- solutions(lambda([B::out] is nondet, (edge12(A, B))), Bs).
+ solutions((pred(B::out) is nondet :- edge12(A, B)), Bs).
:- pred write_ints(list(int)::in, io__state::di, io__state::uo) is det.
Index: tests/hard_coded/common_type_cast.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/common_type_cast.m,v
retrieving revision 1.2
diff -u -r1.2 common_type_cast.m
--- tests/hard_coded/common_type_cast.m 26 May 2003 09:01:06 -0000 1.2
+++ tests/hard_coded/common_type_cast.m 9 Jul 2004 07:01:13 -0000
@@ -19,7 +19,7 @@
:- import_module int, float.
main -->
- { Pred = lambda([Int::in, Float::out] is det, Float = float(Int)) },
+ { Pred = (pred(Int::in, Float::out) is det :- Float = float(Int)) },
{ test(Pred, error("error"), Output1) },
{ test(Pred, ok(1), Output2) },
io__write(Output1),
Index: tests/hard_coded/cycles.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/cycles.m,v
retrieving revision 1.2
diff -u -r1.2 cycles.m
--- tests/hard_coded/cycles.m 3 Jul 1997 08:47:12 -0000 1.2
+++ tests/hard_coded/cycles.m 9 Jul 2004 07:01:40 -0000
@@ -42,7 +42,7 @@
:- pred cycles(node::in, list(list(node))::out) is det.
cycles(N, Nodes) :-
- solutions(lambda([C::out] is nondet, (cycle(N, C))), Nodes).
+ solutions((pred(C::out) is nondet :- cycle(N, C)), Nodes).
%--------------------------------------------------
:- pred cycle(node::in, list(node)::out) is nondet.
Index: tests/hard_coded/cycles2.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/cycles2.m,v
retrieving revision 1.1
diff -u -r1.1 cycles2.m
--- tests/hard_coded/cycles2.m 4 May 1998 05:15:50 -0000 1.1
+++ tests/hard_coded/cycles2.m 9 Jul 2004 07:02:13 -0000
@@ -91,7 +91,7 @@
:- pred cycles(node::in, list(list(node))::out) is det.
cycles(N, Nodes) :-
- solutions(lambda([C::out] is nondet, (cycle(N, C))), Nodes).
+ solutions((pred(C::out) is nondet :- cycle(N, C)), Nodes).
%--------------------------------------------------
Index: tests/hard_coded/deep_copy_bug.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/deep_copy_bug.m,v
retrieving revision 1.2
diff -u -r1.2 deep_copy_bug.m
--- tests/hard_coded/deep_copy_bug.m 8 Feb 2000 15:08:12 -0000 1.2
+++ tests/hard_coded/deep_copy_bug.m 9 Jul 2004 07:03:35 -0000
@@ -18,12 +18,11 @@
:- pred test1(io__state::di, io__state::uo) is det.
test1 -->
- { Lambda = lambda([X::out] is nondet,
- (
+ { Lambda = (pred(X::out) is nondet :-
varset__init(Varset0),
varset__new_vars(Varset0, 10, Vars, _),
list__member(X, Vars)
- )) },
+ ) },
{ solutions(Lambda, List) },
io__write(List),
io__write_string("\n").
Index: tests/hard_coded/lp.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/lp.m,v
retrieving revision 1.3
diff -u -r1.3 lp.m
--- tests/hard_coded/lp.m 8 Nov 2002 17:15:50 -0000 1.3
+++ tests/hard_coded/lp.m 10 Jul 2004 11:03:38 -0000
@@ -49,10 +49,10 @@
(
Resolved = yes,
index(Tableau, N, M, 0, M, ObjVal),
- GetObjVar = lambda([Var::out] is nondet, (
+ GetObjVar = (pred(Var::out) is nondet :-
list__member(Coeff, Objective),
Coeff = Var - _
- )),
+ ),
solutions(GetObjVar, ObjVars),
map__init(ObjVarVals0),
list__foldl(objvarval(Tableau, VarNumbers, N, M), ObjVars,
@@ -85,11 +85,11 @@
number_vars(VarList, 0, VarNumbers0, VarNumbers),
(
Dir = max,
- Neg = lambda([Pair0::in, Pair::out] is det, (
+ Neg = (pred(Pair0::in, Pair::out) is det :-
Pair0 = V - X0,
X1 is -X0,
Pair = V - (X1)
- )),
+ ),
list__map(Neg, Objective, NegObjective)
;
Dir = min,
@@ -127,7 +127,7 @@
simplify(eqn(Coeffs0, Op, Const), eqn(Coeffs, Op, Const)) :-
map__init(CoeffMap0),
- AddCoeff = lambda([Pair::in, Map0::in, Map::out] is det, (
+ AddCoeff = (pred(Pair::in, Map0::in, Map::out) is det :-
Pair = Var - Coeff,
( map__search(Map0, Var, Acc0) ->
Acc1 = Acc0
@@ -136,7 +136,7 @@
),
Acc is Acc1 + Coeff,
map__set(Map0, Var, Acc, Map)
- )),
+ ),
list__foldl(AddCoeff, Coeffs0, CoeffMap0, CoeffMap),
map__to_assoc_list(CoeffMap, Coeffs).
@@ -144,7 +144,7 @@
:- mode collect_vars(in, in, out) is det.
collect_vars(Eqns, Obj, Vars) :-
- GetVar = lambda([Var::out] is nondet, (
+ GetVar = (pred(Var::out) is nondet :-
(
list__member(Eqn, Eqns),
Eqn = eqn(Coeffs, _, _),
@@ -154,7 +154,7 @@
list__member(Pair, Obj),
Pair = Var - _
)
- )),
+ ),
solutions(GetVar, VarList),
set__list_to_set(VarList, Vars).
@@ -198,12 +198,12 @@
objvarval(Tableau, VarNumbers, N, M, Var, ObjVarVals0, ObjVarVals) :-
map__lookup(VarNumbers, Var, Col),
- SelectRow = lambda([VV::out] is nondet, (
+ SelectRow = (pred(VV::out) is nondet :-
between(1, N, Row),
index(Tableau, N, M, Row, Col, V),
V = 1.0,
index(Tableau, N, M, Row, M, VV)
- )),
+ ),
solutions(SelectRow, ObjVarValList),
(
ObjVarValList = [ObjVarVal|_]
@@ -219,8 +219,8 @@
:- mode simplex(in, in, in, out, out, di, uo) is cc_multi.
simplex(N, M, A0, A, Result, IO0, IO) :-
- AllColumns = lambda([Col::out] is nondet, between(0, M-1, Col)),
- MinAgg = lambda([Col::in, Min0::in, Min::out] is det, (
+ AllColumns = (pred(Col::out) is nondet :- between(0, M-1, Col)),
+ MinAgg = (pred(Col::in, Min0::in, Min::out) is det :-
(
Min0 = no,
index(A0, N, M, 0, Col, MinVal),
@@ -238,7 +238,7 @@
Min = Min0
)
)
- )),
+ ),
unsorted_aggregate(AllColumns, MinAgg, no, MinResult),
(
MinResult = no,
@@ -247,8 +247,8 @@
Result = yes
;
MinResult = yes(Q - _Val),
- AllRows = lambda([Row::out] is nondet, between(1, N, Row)),
- MaxAgg = lambda([Row::in, Max0::in, Max::out] is det, (
+ AllRows = (pred(Row::out) is nondet :- between(1, N, Row)),
+ MaxAgg = (pred(Row::in, Max0::in, Max::out) is det :-
(
Max0 = no,
index(A0, N, M, Row, Q, MaxVal),
@@ -273,7 +273,7 @@
Max = Max0
)
)
- )),
+ ),
unsorted_aggregate(AllRows, MaxAgg, no, MaxResult),
(
MaxResult = no,
@@ -304,37 +304,37 @@
pivot(P, Q, N, M, A0, A) :-
index(A0, N, M, P, Q, Apq),
- MostCells = lambda([Cell::out] is nondet, (
+ MostCells = (pred(Cell::out) is nondet :-
between(0, N, J),
J \= P,
between(0, M, K),
K \= Q,
Cell = cell(J, K)
- )),
- ScaleCell = lambda([Cell::in, T0::in, T::out] is det, (
+ ),
+ ScaleCell = (pred(Cell::in, T0::in, T::out) is det :-
Cell = cell(J, K),
index(T0, N, M, J, K, Ajk),
index(T0, N, M, J, Q, Ajq),
index(T0, N, M, P, K, Apk),
NewAjk is Ajk - Apk * Ajq / Apq,
set_index(T0, N, M, J, K, NewAjk, T)
- )),
+ ),
unsorted_aggregate(MostCells, ScaleCell, A0, A1),
- QColumn = lambda([Cell::out] is nondet, (
+ QColumn = (pred(Cell::out) is nondet :-
between(0, N, J),
Cell = cell(J, Q)
- )),
- Zero = lambda([Cell::in, T0::in, T::out] is det, (
+ ),
+ Zero = (pred(Cell::in, T0::in, T::out) is det :-
Cell = cell(J, K),
set_index(T0, N, M, J, K, 0.0, T)
- )),
+ ),
aggregate(QColumn, Zero, A1, A2),
- PRow = lambda([K::out] is nondet, between(0, M, K)),
- ScaleRow = lambda([K::in, T0::in, T::out] is det, (
+ PRow = (pred(K::out) is nondet :- between(0, M, K)),
+ ScaleRow = (pred(K::in, T0::in, T::out) is det :-
index(T0, N, M, P, K, Apk),
NewApk is Apk / Apq,
set_index(T0, N, M, P, K, NewApk, T)
- )),
+ ),
aggregate(PRow, ScaleRow, A2, A3),
set_index(A3, N, M, P, Q, 1.0, A).
Index: tests/hard_coded/merge_and_remove_dups.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/merge_and_remove_dups.m,v
retrieving revision 1.2
diff -u -r1.2 merge_and_remove_dups.m
--- tests/hard_coded/merge_and_remove_dups.m 1 Dec 2003 15:56:08 -0000 1.2
+++ tests/hard_coded/merge_and_remove_dups.m 9 Jul 2004 07:04:21 -0000
@@ -20,8 +20,8 @@
main -->
{ List1 = [1,2,3],
List2 = [3,4,5],
- P = lambda([I1::in,I2::in,R::out] is det,
- (compare(R,I1,I2)) ),
+ P = (pred(I1::in,I2::in,R::out) is det :-
+ compare(R,I1,I2) ),
list__merge_and_remove_dups(P,List1,List2,List3) },
io__write_string("List1: "),
io__print(List1),
Index: tests/hard_coded/quantifier.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/quantifier.m,v
retrieving revision 1.1
diff -u -r1.1 quantifier.m
--- tests/hard_coded/quantifier.m 12 Jun 1998 07:05:44 -0000 1.1
+++ tests/hard_coded/quantifier.m 9 Jul 2004 07:05:02 -0000
@@ -24,7 +24,7 @@
main -->
- ( {P = lambda([X :: out] is det, X = 6),
+ ( {P = (pred(X :: out) is det :- X = 6),
foo(Q),
all [X] (call(P,X) <=> call(Q,X))}
->
Index: tests/hard_coded/quantifier2.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/quantifier2.m,v
retrieving revision 1.1
diff -u -r1.1 quantifier2.m
--- tests/hard_coded/quantifier2.m 25 Oct 1999 03:53:14 -0000 1.1
+++ tests/hard_coded/quantifier2.m 9 Jul 2004 07:05:31 -0000
@@ -25,7 +25,7 @@
main -->
(
- { P = lambda([I :: in, X :: out] is semidet, (I > 0, X = 6)),
+ { P = (pred(I :: in, X :: out) is semidet :- I > 0, X = 6),
foo(Q),
J = 1,
(call(P,J,_X) <=> call(Q,J,_Y)) }
Index: tests/invalid/undef_lambda_mode.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/undef_lambda_mode.m,v
retrieving revision 1.1
diff -u -r1.1 undef_lambda_mode.m
--- tests/invalid/undef_lambda_mode.m 11 Jun 1996 06:33:05 -0000 1.1
+++ tests/invalid/undef_lambda_mode.m 9 Jul 2004 07:11:51 -0000
@@ -7,5 +7,5 @@
:- implementation.
-test(lambda([X::junk] is semidet, X = 1)).
+test((pred(X::junk) is semidet :- X = 1)).
Index: tests/invalid/purity/purity.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/purity/purity.err_exp,v
retrieving revision 1.6
diff -u -r1.6 purity.err_exp
--- tests/invalid/purity/purity.err_exp 29 May 2003 04:05:37 -0000 1.6
+++ tests/invalid/purity/purity.err_exp 10 Jul 2004 14:04:54 -0000
@@ -1,52 +1,52 @@
-purity.m:028: In predicate `purity.w1/0':
-purity.m:028: warning: declared `impure' but actually pure.
-purity.m:032: In predicate `purity.w2/0':
-purity.m:032: warning: declared `semipure' but actually pure.
-purity.m:036: In predicate `purity.w3/0':
-purity.m:036: warning: declared `impure' but actually semipure.
-purity.m:040: In predicate `purity.w4/0':
-purity.m:040: warning: unnecessary `promise_pure' pragma.
-purity.m:045: In predicate `purity.w5/0':
-purity.m:045: warning: declared `impure' but promised pure.
-purity.m:050: In predicate `purity.w6/0':
-purity.m:050: warning: declared `semipure' but promised pure.
-purity.m:059: In predicate `purity.e1/0':
-purity.m:059: purity error: predicate is impure.
-purity.m:059: It must be declared `impure' or promised pure.
-purity.m:064: In predicate `purity.e2/0':
-purity.m:064: purity error: predicate is semipure.
-purity.m:064: It must be declared `semipure' or promised pure.
-purity.m:068: In predicate `purity.e3/0':
-purity.m:068: purity error: predicate is impure.
-purity.m:068: It must be declared `impure' or promised semipure.
-purity.m:074: In call to impure predicate `purity.imp/0':
-purity.m:074: purity error: call must be preceded by `impure' indicator.
-purity.m:078: In call to semipure predicate `purity.semi/0':
-purity.m:078: purity error: call must be preceded by `semipure' indicator.
-purity.m:112: In call to impure predicate `purity.imp1/1':
-purity.m:112: purity error: call must be preceded by `impure' indicator.
-purity.m:112: Purity error in closure: closure body is impure,
-purity.m:112: but closure was not declared `impure.'
-purity.m:118: In call to semipure predicate `purity.semi/0':
-purity.m:118: purity error: call must be preceded by `semipure' indicator.
-purity.m:118: Purity error in closure: closure body is semipure,
-purity.m:118: but closure was not declared `semipure.'
-purity.m:093: In unification predicate for type purity.e8:
-purity.m:093: purity error: predicate is impure.
-purity.m:093: It must be pure.
-purity.m:101: In unification predicate for type purity.e9:
-purity.m:101: purity error: predicate is semipure.
-purity.m:101: It must be pure.
-purity.m:083: In clause for `e6':
-purity.m:083: in argument 1 of call to predicate `purity.in/1':
-purity.m:083: mode error: variable `X' has instantiatedness `free',
-purity.m:083: expected instantiatedness was `ground'.
-purity.m:083: The goal could not be reordered, because
-purity.m:083: it was followed by an impure goal.
-purity.m:084: This is the location of the impure goal.
-purity.m:090: In clause for `e7':
-purity.m:090: in argument 1 of call to predicate `purity.imp1/1':
+purity.m:035: In predicate `purity.w1/0':
+purity.m:035: warning: declared `impure' but actually pure.
+purity.m:039: In predicate `purity.w2/0':
+purity.m:039: warning: declared `semipure' but actually pure.
+purity.m:043: In predicate `purity.w3/0':
+purity.m:043: warning: declared `impure' but actually semipure.
+purity.m:047: In predicate `purity.w4/0':
+purity.m:047: warning: unnecessary `promise_pure' pragma.
+purity.m:052: In predicate `purity.w5/0':
+purity.m:052: warning: declared `impure' but promised pure.
+purity.m:057: In predicate `purity.w6/0':
+purity.m:057: warning: declared `semipure' but promised pure.
+purity.m:066: In predicate `purity.e1/0':
+purity.m:066: purity error: predicate is impure.
+purity.m:066: It must be declared `impure' or promised pure.
+purity.m:071: In predicate `purity.e2/0':
+purity.m:071: purity error: predicate is semipure.
+purity.m:071: It must be declared `semipure' or promised pure.
+purity.m:075: In predicate `purity.e3/0':
+purity.m:075: purity error: predicate is impure.
+purity.m:075: It must be declared `impure' or promised semipure.
+purity.m:081: In call to impure predicate `purity.imp/0':
+purity.m:081: purity error: call must be preceded by `impure' indicator.
+purity.m:085: In call to semipure predicate `purity.semi/0':
+purity.m:085: purity error: call must be preceded by `semipure' indicator.
+purity.m:119: In call to impure predicate `purity.imp1/1':
+purity.m:119: purity error: call must be preceded by `impure' indicator.
+purity.m:119: Purity error in closure: closure body is impure,
+purity.m:119: but closure was not declared `impure.'
+purity.m:125: In call to semipure predicate `purity.semi/1':
+purity.m:125: purity error: call must be preceded by `semipure' indicator.
+purity.m:125: Purity error in closure: closure body is semipure,
+purity.m:125: but closure was not declared `semipure.'
+purity.m:100: In unification predicate for type purity.e8:
+purity.m:100: purity error: predicate is impure.
+purity.m:100: It must be pure.
+purity.m:108: In unification predicate for type purity.e9:
+purity.m:108: purity error: predicate is semipure.
+purity.m:108: It must be pure.
+purity.m:090: In clause for `e6':
+purity.m:090: in argument 1 of call to predicate `purity.in/1':
purity.m:090: mode error: variable `X' has instantiatedness `free',
purity.m:090: expected instantiatedness was `ground'.
-purity.m:090: The goal could not be reordered, because it was impure.
+purity.m:090: The goal could not be reordered, because
+purity.m:090: it was followed by an impure goal.
+purity.m:091: This is the location of the impure goal.
+purity.m:097: In clause for `e7':
+purity.m:097: in argument 1 of call to predicate `purity.imp1/1':
+purity.m:097: mode error: variable `X' has instantiatedness `free',
+purity.m:097: expected instantiatedness was `ground'.
+purity.m:097: The goal could not be reordered, because it was impure.
For more information, try recompiling with `-E'.
Index: tests/invalid/purity/purity.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/purity/purity.m,v
retrieving revision 1.2
diff -u -r1.2 purity.m
--- tests/invalid/purity/purity.m 7 Nov 2002 16:17:09 -0000 1.2
+++ tests/invalid/purity/purity.m 10 Jul 2004 13:47:58 -0000
@@ -15,12 +15,19 @@
:- mode in(in) is semidet.
in(a).
+:- semipure pred semi(foo::in) is semidet.
+:- pragma foreign_proc("C",
+ semi(X::in),
+ [will_not_call_mercury, promise_semipure],
+"
+ /* X */
+ SUCCESS_INDICATOR=0;
+").
+
:- impure pred imp1(foo).
:- mode imp1(in) is semidet.
:- pragma c_code(imp1(_X::in), will_not_call_mercury, "SUCCESS_INDICATOR=0;").
-
-
%----------------------------------------------------------------
% Warnings
@@ -109,14 +116,14 @@
:- pred e10 is semidet.
e10 :-
- Goal1 = lambda([] is semidet, imp1(b)),
- call(Goal1).
+ Goal1 = (pred(X::in) is semidet :- imp1(X)),
+ call(Goal1, b).
:- pred e11 is semidet.
e11 :-
- Goal2 = lambda([] is semidet, semi),
- call(Goal2).
+ Goal2 = (pred(X::in) is semidet :- semi(X)),
+ call(Goal2, b).
:- import_module std_util.
imp.
Index: tests/tabling/fib_string.m
===================================================================
RCS file: /home/mercury1/repository/tests/tabling/fib_string.m,v
retrieving revision 1.2
diff -u -r1.2 fib_string.m
--- tests/tabling/fib_string.m 31 May 2004 04:13:26 -0000 1.2
+++ tests/tabling/fib_string.m 9 Jul 2004 07:13:05 -0000
@@ -165,7 +165,7 @@
:- pragma memo(digits/1).
digits(PairList) :-
- solutions(lambda([Pair::out] is multi, (
+ solutions((pred(Pair::out) is multi :-
translate_digit_2(Int, String),
Pair = String - Int
- )), PairList).
+ ), PairList).
Index: tests/valid/agc_ho_pred.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/agc_ho_pred.m,v
retrieving revision 1.1
diff -u -r1.1 agc_ho_pred.m
--- tests/valid/agc_ho_pred.m 3 Jul 1997 07:18:27 -0000 1.1
+++ tests/valid/agc_ho_pred.m 9 Jul 2004 07:23:07 -0000
@@ -91,9 +91,9 @@
;
OptionOps = option_ops(_, _, OptionDefaultsPred, _)
),
- solutions(lambda([OptionDataPair::out] is nondet, (
+ solutions((pred(OptionDataPair::out) is nondet :-
OptionDataPair = Option - OptionData,
call(OptionDefaultsPred, Option, OptionData)
- )), OptionDefaultsList),
+ ), OptionDefaultsList),
Args = OptionDefaultsList.
Index: tests/valid/higher_order2.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/higher_order2.m,v
retrieving revision 1.1
diff -u -r1.1 higher_order2.m
--- tests/valid/higher_order2.m 24 Apr 1996 05:21:49 -0000 1.1
+++ tests/valid/higher_order2.m 9 Jul 2004 07:24:21 -0000
@@ -14,5 +14,5 @@
:- pred qqq(list(int), pred(int, int)).
:- mode qqq(in, pred(in, out) is det) is det.
qqq(L, F) :-
- ppp(lambda([I::in, O::out] is det, call(F, I, O)), L).
+ ppp((pred(I::in, O::out) is det :- call(F, I, O)), L).
Index: tests/valid/higher_order3.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/higher_order3.m,v
retrieving revision 1.1
diff -u -r1.1 higher_order3.m
--- tests/valid/higher_order3.m 24 Apr 1996 05:21:50 -0000 1.1
+++ tests/valid/higher_order3.m 9 Jul 2004 07:24:45 -0000
@@ -6,7 +6,7 @@
:- implementation.
:- import_module list.
-bar :- foo(lambda([X::in] is semidet, X = [_|_]), []).
+bar :- foo((pred(X::in) is semidet :- X = [_|_]), []).
:- pred foo(pred(T), T).
:- mode foo(pred(in) is semidet, in) is semidet.
Index: tests/valid/inlining_bug.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/inlining_bug.m,v
retrieving revision 1.1
diff -u -r1.1 inlining_bug.m
--- tests/valid/inlining_bug.m 25 Feb 1998 00:12:16 -0000 1.1
+++ tests/valid/inlining_bug.m 9 Jul 2004 07:23:51 -0000
@@ -22,7 +22,7 @@
:- type my_pair(A) ---> pair(A, A).
calling_pred(_) :-
- Plus1 = lambda([Int0::in, IntPair::out] is det,
+ Plus1 = (pred(Int0::in, IntPair::out) is det :-
IntPair = pair(Int0, Int0)),
called_pred(Plus1, [1,2,3], [X | Ys]),
X = pair(2, 2),
Index: tests/valid/intermod_lambda2.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/intermod_lambda2.m,v
retrieving revision 1.5
diff -u -r1.5 intermod_lambda2.m
--- tests/valid/intermod_lambda2.m 20 Mar 2004 04:58:06 -0000 1.5
+++ tests/valid/intermod_lambda2.m 9 Jul 2004 07:25:45 -0000
@@ -20,9 +20,9 @@
sol(Generator, List) :-
Test = ((pred) is semidet),
TestFunc = ((func) = 1),
- Cons = lambda([Elem::in, L0::in, L::out] is det, (
+ Cons = (pred(Elem::in, L0::in, L::out) is det :-
intermod_lambda2__cons(Elem, L0, L)
- )),
+ ),
t(Test, TestFunc, Generator, Cons, [], List).
:- pred intermod_lambda2__cons(T::in, list(T)::in, list(T)::out) is det.
Index: tests/valid/intermod_test.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/intermod_test.m,v
retrieving revision 1.3
diff -u -r1.3 intermod_test.m
--- tests/valid/intermod_test.m 3 Dec 1999 12:55:22 -0000 1.3
+++ tests/valid/intermod_test.m 9 Jul 2004 07:26:04 -0000
@@ -18,7 +18,7 @@
p(X) :-
Y = f(1),
Y = f(_),
- Lambda = lambda([Z::int_mode] is det, Z = 2),
+ Lambda = (pred(Z::int_mode) is det :- Z = 2),
local(Lambda, X),
intermod_test2__baz(X).
Index: tests/valid/intermod_typeclass.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/intermod_typeclass.m,v
retrieving revision 1.1
diff -u -r1.1 intermod_typeclass.m
--- tests/valid/intermod_typeclass.m 3 Dec 1999 12:55:22 -0000 1.1
+++ tests/valid/intermod_typeclass.m 9 Jul 2004 07:28:08 -0000
@@ -18,7 +18,7 @@
p(X) :-
Y = f(1),
Y = f(_),
- Lambda = lambda([Z::int_mode] is det, Z = 2),
+ Lambda = (pred(Z::int_mode) is det :- Z = 2),
local(Lambda, X),
intermod_typeclass2__baz(X).
Index: tests/valid/lambda_inference.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/lambda_inference.m,v
retrieving revision 1.1
diff -u -r1.1 lambda_inference.m
--- tests/valid/lambda_inference.m 28 Jun 1996 05:49:38 -0000 1.1
+++ tests/valid/lambda_inference.m 9 Jul 2004 07:26:33 -0000
@@ -9,7 +9,7 @@
:- implementation.
-ok(Var, lambda([X::in] is semidet, X = 5)) :-
+ok(Var, (pred(X::in) is semidet :- X = 5)) :-
inferred(Var).
:- pred inferred(int).
Index: tests/valid/lambda_instmap_bug.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/lambda_instmap_bug.m,v
retrieving revision 1.2
diff -u -r1.2 lambda_instmap_bug.m
--- tests/valid/lambda_instmap_bug.m 1 Dec 2003 15:56:14 -0000 1.2
+++ tests/valid/lambda_instmap_bug.m 9 Jul 2004 07:27:06 -0000
@@ -23,12 +23,12 @@
% Don't attempt to clear or drop streams.
IsNotStreamClear =
- lambda([Instr::in] is semidet, (
+ (pred(Instr::in) is semidet :-
\+ (
( Instr = clear(Rel) - _
; Instr = drop(Rel) - _
),
set__member(Rel, Streams)
)
- )),
+ ),
list__filter(IsNotStreamClear, Instrs0, Instrs).
Index: tests/valid/lambda_struct_bug.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/lambda_struct_bug.m,v
retrieving revision 1.2
diff -u -r1.2 lambda_struct_bug.m
--- tests/valid/lambda_struct_bug.m 26 May 2003 09:01:40 -0000 1.2
+++ tests/valid/lambda_struct_bug.m 9 Jul 2004 07:27:37 -0000
@@ -26,7 +26,7 @@
:- import_module int, require.
adj(pos(X, Y), Adjs) :-
- Pred = lambda([Adj::out] is nondet, (
+ Pred = (pred(Adj::out) is nondet :-
(
X1 = X - 1,
Adj = adj(pos(X1, Y), pos(X, Y))
@@ -43,5 +43,5 @@
Adj = adj(pos(A, B), _),
A >= 0, A =< 10, % XXX
B >= 0, B =< 10 % XXX
- )),
+ ),
solutions(Pred, Adjs).
Index: tests/valid/lambda_type.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/lambda_type.m,v
retrieving revision 1.2
diff -u -r1.2 lambda_type.m
--- tests/valid/lambda_type.m 4 Nov 1996 08:18:58 -0000 1.2
+++ tests/valid/lambda_type.m 9 Jul 2004 07:29:14 -0000
@@ -8,10 +8,10 @@
:- implementation.
p :-
- _X = lambda([W::out] is det, W = 1),
- _Y = lambda([W::out] is det, W = a).
+ _X = (pred(W::out) is det :- W = 1),
+ _Y = (pred(W::out) is det :- W = a).
q :-
- _X = lambda([W::out] is det, (W = 1, Z = 1)),
- _Y = lambda([W::out] is det, (W = a, Z = a)).
+ _X = (pred(W::out) is det :- W = 1, Z = 1),
+ _Y = (pred(W::out) is det :- W = a, Z = a).
Index: tests/valid/lazy_list.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/lazy_list.m,v
retrieving revision 1.2
diff -u -r1.2 lazy_list.m
--- tests/valid/lazy_list.m 1 Dec 2003 15:56:14 -0000 1.2
+++ tests/valid/lazy_list.m 9 Jul 2004 07:43:52 -0000
@@ -369,7 +369,7 @@
lazy_list__append([X | Xs], Ys, [X | Zs]) :-
lazy_list__append(Xs, Ys, Zs).
lazy_list__append(lazy(P0), Ys, lazy(P)) :-
- P = lambda([Zs::out] is det, (P0(Xs), lazy_list__append(Xs, Ys, Zs))).
+ P = (pred(Zs::out) is det :- P0(Xs), lazy_list__append(Xs, Ys, Zs)).
%-----------------------------------------------------------------------------%
@@ -378,7 +378,7 @@
lazy_list__condense(Ls, R1),
lazy_list__append(L, R1, R).
lazy_list__condense(lazy(P0), lazy(P)) :-
- P = lambda([L::out] is det, (P0(L0), lazy_list__condense(L0, L))).
+ P = (pred(L::out) is det :- P0(L0), lazy_list__condense(L0, L)).
%-----------------------------------------------------------------------------%
@@ -416,8 +416,8 @@
lazy_list__delete_all(Xs, Y, Zs1)
).
lazy_list__delete_all(lazy(P0), Elem, lazy(P)) :-
- P = lambda([L::out] is det,
- (P0(L0), lazy_list__delete_all(L0, Elem, L))).
+ P = (pred(L::out) is det :-
+ P0(L0), lazy_list__delete_all(L0, Elem, L)).
lazy_list__delete_elems(Xs, [], Xs).
lazy_list__delete_elems(Xs, [E | Es], Zs) :-
@@ -475,10 +475,10 @@
lazy_list__merge([X|Xs], Ys, Zs)
).
lazy_list__merge([X|Xs], lazy(YsP), lazy(ZsP)) :-
- ZsP = lambda([Zs::out] is det, (
+ ZsP = (pred(Zs::out) is det :-
YsP(Ys),
lazy_list__merge([X|Xs], Ys, Zs)
- )).
+ ).
lazy_list__merge(lazy(XsP), Ys, Zs) :-
XsP(Xs),
lazy_list__merge(Xs, Ys, Zs).
@@ -509,10 +509,10 @@
lazy_list__remove_adjacent_dups([X|Xs], L) :-
lazy_list__remove_adjacent_dups_2(Xs, X, L).
lazy_list__remove_adjacent_dups(lazy(P0), lazy(P)) :-
- P = lambda([L::out] is det, (
+ P = (pred(L::out) is det :-
P0(L0),
lazy_list__remove_adjacent_dups(L0, L)
- )).
+ ).
:- pred lazy_list__remove_adjacent_dups_2(lazy_list(T), T, lazy_list(T)).
:- mode lazy_list__remove_adjacent_dups_2(in(lazy_list), in, out(lazy_list))
@@ -527,10 +527,10 @@
lazy_list__remove_adjacent_dups_2(Xs, X1, L0)
).
lazy_list__remove_adjacent_dups_2(lazy(P0), X, lazy(P)) :-
- P = lambda([L::out] is det, (
+ P = (pred(L::out) is det :-
P0(L0),
lazy_list__remove_adjacent_dups_2(L0, X, L)
- )).
+ ).
%-----------------------------------------------------------------------------%
@@ -538,7 +538,7 @@
lazy_list__zip([A|As], Bs, [A|Cs]) :-
lazy_list__zip2(As, Bs, Cs).
lazy_list__zip(lazy(P0), Bs, lazy(P)) :-
- P = lambda([Cs::out] is det, (P0(As), lazy_list__zip(As, Bs, Cs))).
+ P = (pred(Cs::out) is det :- P0(As), lazy_list__zip(As, Bs, Cs)).
:- pred lazy_list__zip2(lazy_list(T), lazy_list(T), lazy_list(T)).
:- mode lazy_list__zip2(in(lazy_list), in(lazy_list), out(lazy_list)) is det.
@@ -549,7 +549,7 @@
lazy_list__zip2(As, [B|Bs], [B|Cs]) :-
lazy_list__zip(As, Bs, Cs).
lazy_list__zip2(As, lazy(P0), lazy(P)) :-
- P = lambda([Cs::out] is det, (P0(Bs), lazy_list__zip(As, Bs, Cs))).
+ P = (pred(Cs::out) is det :- P0(Bs), lazy_list__zip(As, Bs, Cs)).
%-----------------------------------------------------------------------------%
@@ -654,21 +654,21 @@
call(P, H0, H),
lazy_list__map(P, T0, T).
lazy_list__map(As, lazy(P0), lazy(P)) :-
- P = lambda([Cs::out] is det, (P0(Bs), lazy_list__map(As, Bs, Cs))).
+ P = (pred(Cs::out) is det :- P0(Bs), lazy_list__map(As, Bs, Cs)).
lazy_list__filter(_, [], []).
lazy_list__filter(P, [H|T], lazy(Pred)) :-
lazy_list__filter(P, T, L1),
- Pred = lambda([L::out] is det, (
+ Pred = (pred(L::out) is det :-
( P(H) ->
L = [H|L1]
;
L = L1
)
- )).
+ ).
lazy_list__filter(P, lazy(ListP), lazy(TrueP)) :-
ListP(L0),
- TrueP = lambda([L::out] is det, lazy_list__filter(P, L0, L)).
+ TrueP = (pred(L::out) is det :- lazy_list__filter(P, L0, L)).
/* NYI
lazy_list__merge(_P, [], L, L).
--------------------------------------------------------------------------
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