[mercury-users] Re: your mail

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Jul 20 13:27:02 AEST 2004


On 19-Jul-2004, hanberg at ruc.dk <hanberg at ruc.dk> wrote:
> filereader2.m:072: In clause for `proveable2(in, ui, uo)':
> filereader2.m:072:   in argument 2 of call to predicate `io:print/3':
> filereader2.m:072:   unique-mode error: the called procedure would clobber
> filereader2.m:072:   its argument, but variable `IO_In' is still live.
> For more information, try recompiling with `-E'.

> I don't really know why that is. everything is deterministic except the
> proveable procedure. I hope someone can help me.

The problem is not determinism, it is that your code is trying to destructively
update something that is not allowed to be destructively updated, in this
case IO_In.

> :- pred proveable2(list(expr(T)), io__state, io__state).
> :- mode proveable2(in, ui, uo) is det.

The ui mode on the first io__state tells Mercury that the caller that the
caller still has a reference on that argument, IO_In. The body of proveable2
cannot destructively updated IO_In until the caller has released its last
reference to it.

The fix is trivial: change the ui to di. The destructive input (di) mode
allows the predicate to clobber the argument; plain unique input (ui) mode
does not.

Zoltan Somogyi <zs at cs.mu.OZ.AU> http://www.cs.mu.oz.au/~zs/
Department of Computer Science and Software Engineering, Univ. of Melbourne
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list