[m-rev.] for review: allow retries over polymorphic procs with IO

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed May 11 18:02:20 AEST 2005


On Wed, 11 May 2005, Mark Brown wrote:

> On 11-May-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > tests/debugger/Mmakefile:
> > tests/debugger/poly_io_retry.exp:
> > tests/debugger/poly_io_retry.inp:
> > tests/debugger/poly_io_retry.m:
> > 	Test we can retry over a procedure with an io.state in it's
> > 	polymorphic arguments.  Prevoiusly the retry would give an error
> > 	message like "some inputs are missing".
>
> You should also test that retries are still not allowed over destructive
> update of polymorphic data where the type is _not_ io.
>

Okay.  Here is the new version of the test:

Index: tests/debugger/poly_io_retry.exp
===================================================================
RCS file: tests/debugger/poly_io_retry.exp
diff -N tests/debugger/poly_io_retry.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/poly_io_retry.exp	11 May 2005 07:52:34 -0000
@@ -0,0 +1,21 @@
+      E1:     C1 CALL pred poly_io_retry.main/2-0 (det) poly_io_retry.m:13
+mdb> mdb> Contexts will not be printed.
+mdb> echo on
+Command echo enabled.
+mdb>
+      E2:     C2 CALL pred poly_io_retry.polycall/3-0 (det)
+mdb> f
+hello      E3:     C2 EXIT pred poly_io_retry.polycall/3-0 (det)
+mdb> retry
+Retry across I/O operations is not always safe.
+Are you sure you want to do it? y
+      E2:     C2 CALL pred poly_io_retry.polycall/3-0 (det)
+mdb> f
+hello      E3:     C2 EXIT pred poly_io_retry.polycall/3-0 (det)
+mdb>
+      E4:     C3 CALL pred poly_io_retry.polycall/3-1 (det)
+mdb> f
+      E5:     C3 EXIT pred poly_io_retry.polycall/3-1 (det)
+mdb> retry
+Cannot perform retry because the values of some input arguments are missing.
+mdb> quit -y
Index: tests/debugger/poly_io_retry.inp
===================================================================
RCS file: tests/debugger/poly_io_retry.inp
diff -N tests/debugger/poly_io_retry.inp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/poly_io_retry.inp	11 May 2005 07:52:05 -0000
@@ -0,0 +1,12 @@
+register --quiet
+context none
+echo on
+
+f
+retry
+y
+f
+
+f
+retry
+quit -y
Index: tests/debugger/poly_io_retry.m
===================================================================
RCS file: tests/debugger/poly_io_retry.m
diff -N tests/debugger/poly_io_retry.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/debugger/poly_io_retry.m	11 May 2005 07:47:58 -0000
@@ -0,0 +1,29 @@
+:- module poly_io_retry.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module array, list.
+
+main(!IO) :-
+	polycall(io.write_string("hello"), !IO),
+	A = array([0]),
+	polycall(array_update, A, B),
+	io.write(B, !IO),
+	nl(!IO).
+
+:- pred polycall(pred(T, T), T, T).
+:- mode polycall(in(pred(di, uo) is det), di, uo) is det.
+:- mode polycall(in(pred(array_di, array_uo) is det), array_di, array_uo)
+	is det.
+
+polycall(P, !S) :- P(!S).
+
+:- pred array_update(array(int)::array_di, array(int)::array_uo) is det.
+
+array_update(!A) :- !:A = !.A ^ elem(0) := 1.

> Otherwise this looks good.
>

Cheers,

Ian.

--------------------------------------------------------------------------
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