[m-rev.] for review: library changes for `mmc --make' on Windows
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Jul 28 15:49:44 AEST 2003
On 20-Jul-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 15-Jul-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 15-Jul-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > > library/exception.m:
> > ...
> > > Add predicates try_det, try_io_det and try_store_det,
> > > which only have one mode so they are more convenient
> > > to pass to promise_only solution.
> >
> > That part of the log message is no longer valid.
>
> I decided to leave these -- I've wanted them often enough.
(Sorry, I missed that first time around.)
The documentation for these predicates encourages their use
in combination with promise_only_solution, which is unsafe,
since you can't be sure that there will only be one solution
without making unwarranted assumptions about the implementation.
For example, an implementation might treat stack overflow as
an exception, and you can't be sure that the stack won't overflow.
I don't think we should be encouraging bad style, so I think these
routines should be deleted.
Hence I propose the following patch.
Comments?
----------
Estimated hours taken: 0.5
Branches: main
library/exception.m:
Delete the recently-added try_det, try_io_det, and
try_store_det procedures.
NEWS:
Delete the paragraph mentioning that we had added
try_det, try_io_det, and try_store_det.
Workspace: /home/ceres/fjh/mercury
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.315
diff -u -d -r1.315 NEWS
--- NEWS 21 Jul 2003 14:08:32 -0000 1.315
+++ NEWS 28 Jul 2003 05:35:59 -0000
@@ -137,10 +137,6 @@
input_stream_foldl2_io_maybe_stop/{6,7},
binary_input_stream_foldl2_io_maybe_stop/{6,7}.
-* We've added predicates try_det/2, try_io_det/4 and try_store_det/4
- to exception.m. These predicates have only one mode, so it's more
- convenient to pass them to promise_only_solution.
-
* exception.m now contains a predicate finally/6 which can be used to
ensure that resources are released whether a called closure exits
normally or throws an exception.
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.79
diff -u -d -r1.79 exception.m
--- library/exception.m 23 Jul 2003 08:59:05 -0000 1.79
+++ library/exception.m 28 Jul 2003 05:33:06 -0000
@@ -62,11 +62,6 @@
:- mode try(pred(out) is cc_multi, out(cannot_fail)) is cc_multi.
:- mode try(pred(out) is cc_nondet, out) is cc_multi.
-% As above. This version has only one mode, so it can be passed
-% as a closure (e.g. to builtin.promise_only_solution).
-:- pred try_det(pred(T), exception_result(T)).
-:- mode try_det(pred(out) is det, out(cannot_fail)) is cc_multi.
-
%
% try_io(Goal, Result, IO_0, IO):
% Operational semantics:
@@ -88,13 +83,6 @@
:- mode try_io(pred(out, di, uo) is cc_multi,
out(cannot_fail), di, uo) is cc_multi.
-% As above. This version has only one mode, so it can be passed
-% as a closure (e.g. to builtin.promise_only_solution_io).
-:- pred try_io_det(pred(T, io__state, io__state),
- exception_result(T), io__state, io__state).
-:- mode try_io_det(pred(out, di, uo) is det,
- out(cannot_fail), di, uo) is cc_multi.
-
%
% try_store(Goal, Result, Store_0, Store):
% Just like try_io, but for stores rather than io__states.
@@ -106,13 +94,6 @@
:- mode try_store(pred(out, di, uo) is cc_multi,
out(cannot_fail), di, uo) is cc_multi.
-% As above. This version has only one mode, so it can be passed
-% as a closure (e.g. to builtin.promise_only_solution_io).
-:- pred try_store_det(pred(T, store(S), store(S)),
- exception_result(T), store(S), store(S)).
-:- mode try_store_det(pred(out, di, uo) is det,
- out(cannot_fail), di, uo) is cc_multi.
-
%
% try_all(Goal, ResultList):
% Operational semantics:
@@ -416,8 +397,6 @@
builtin_catch(wrap_success_or_failure(Goal), wrap_exception, Result).
*********************/
-try_det(Goal, Result) :- try(Goal, Result).
-
try(Goal, Result) :-
get_determinism(Goal, Detism),
try(Detism, Goal, Result).
@@ -492,8 +471,6 @@
% We need to switch on the Detism argument
% for the same reason as above.
-try_store_det(StoreGoal, Result) --> try_store(StoreGoal, Result).
-
try_store(StoreGoal, Result) -->
{ get_determinism_2(StoreGoal, Detism) },
try_store(Detism, StoreGoal, Result).
@@ -538,8 +515,6 @@
% the store was from the goal which just threw an exception.
unsafe_promise_unique(Store0, Store)
).
-
-try_io_det(IO_Goal, Result) --> try_io(IO_Goal, Result).
try_io(IO_Goal, Result) -->
{ get_determinism_2(IO_Goal, Detism) },
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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