[m-rev.] Tiny addition to store.m
Ralph Becket
rafe at cs.mu.OZ.AU
Wed Jan 29 12:24:16 AEDT 2003
Estimated hours taken: 1
Branches: main
A useful addition to store.m.
library/store.m:
Added copy_mutvar/4.
Fixed an over-long line.
Index: library/store.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/store.m,v
retrieving revision 1.34
diff -u -r1.34 store.m
--- library/store.m 14 Jun 2002 10:18:55 -0000 1.34
+++ library/store.m 29 Jan 2003 01:21:48 -0000
@@ -62,6 +62,14 @@
:- pred store__new_mutvar(T, generic_mutvar(T, S), S, S) <= store(S).
:- mode store__new_mutvar(in, out, di, uo) is det.
+ % copy_mutvar(OldMutvar, NewMutvar, S0, S)
+ % is equivalent to the sequence
+ % get_mutvar(OldMutvar, Value, S0, S1),
+ % new_mutvar(NewMutvar, Value, S1, S )
+:- pred store__copy_mutvar(generic_mutvar(T, S), generic_mutvar(T, S), S, S)
+ <= store(S).
+:- mode store__copy_mutvar(in, out, di, uo) is det.
+
% lookup the value stored in a given mutable variable
:- pred store__get_mutvar(generic_mutvar(T, S), T, S, S) <= store(S).
:- mode store__get_mutvar(in, out, di, uo) is det.
@@ -302,6 +310,10 @@
% matching foreign_proc version.
{ private_builtin__sorry("store__new_mutvar") }.
+copy_mutvar(Mutvar, Copy) -->
+ get_mutvar(Mutvar, Value),
+ new_mutvar(Value, Copy).
+
get_mutvar(_, _) -->
% This version is only used for back-ends for which there is no
% matching foreign_proc version.
@@ -316,7 +328,8 @@
S, S) <= store(S).
:- mode store__unsafe_new_uninitialized_mutvar(out, di, uo) is det.
-:- pragma foreign_proc("C", unsafe_new_uninitialized_mutvar(Mutvar::out, S0::di, S::uo),
+:- pragma foreign_proc("C",
+ unsafe_new_uninitialized_mutvar(Mutvar::out, S0::di, S::uo),
[will_not_call_mercury, promise_pure],
"
MR_incr_hp_msg(Mutvar, 1, MR_PROC_LABEL, ""store:mutvar/2"");
--------------------------------------------------------------------------
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