[m-rev.] Tiny addition to store.m

Ralph Becket rafe at cs.mu.OZ.AU
Wed Jan 29 13:19:53 AEDT 2003


Fergus Henderson, Wednesday, 29 January 2003:
> On 29-Jan-2003, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > A useful addition to store.m.
> > 
> > library/store.m:
> > 	Added copy_mutvar/4.
> > 	Fixed an over-long line.
> 
> That looks fine.  But if it's worth doing there, then it's also worth
> doing in extras/trailed_update/tr_store.m.  I would like to keep the
> interfaces of those two as similar as possible.

Relative diff:

only in patch2:
--- extras/trailed_update/tr_store.m	4 Feb 2002 05:22:31 -0000	1.10
+++ extras/trailed_update/tr_store.m	29 Jan 2003 02:18:18 -0000
@@ -34,6 +34,13 @@
 :- pred tr_store__new_mutvar(T, mutvar(T, S), store(S), store(S)).
 :- mode tr_store__new_mutvar(in, out, mdi, muo) is det.
 
+	% copy_mutvar(Mutvar, Copy, S0, S)
+	% is equivalent to
+	% 	get_mutvar(Mutvar, Value, S0, S1),
+	% 	new_mutvar(Value, Copy,   S1, S )
+:- pred tr_store__copy_mutvar(mutvar(T, S), mutvar(T, S), store(S), store(S)).
+:- mode tr_store__copy_mutvar(in, out, mdi, muo) is det.
+
 	% lookup the value stored in a given mutable variable
 :- pred tr_store__get_mutvar(mutvar(T, S), T, store(S), store(S)).
 :- mode tr_store__get_mutvar(in, out, mdi, muo) is det.
@@ -154,6 +161,10 @@
 	*(MR_Word *)Mutvar = Val;
 	S = S0;
 ").
+
+copy_mutvar(Mutvar, Copy) -->
+	get_mutvar(Mutvar, Val),
+	new_mutvar(Val, Copy).
 
 :- pragma c_code(get_mutvar(Mutvar::in, Val::out, S0::mdi, S::muo),
 		will_not_call_mercury,
--------------------------------------------------------------------------
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