diff: var.m bug fix

Fergus Henderson fjh at kryten.cs.mu.OZ.AU
Sun Sep 28 04:19:10 AEST 1997


extras/trailed_update/var.m:
	Fix a bug: some of the code relied on there always being at least one
	level of indirection (i.e. assumed that the top-level functor of a
	variable representation was always alias/1), but the code to
	initialize a variable with a ground value did not satisfy this
	invariant.
	Also change the top-level functor from var_rep/1 to '$VAR'/1,
	for cosmetic reasons.

Index: var.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/extras/trailed_update/var.m,v
retrieving revision 1.2
diff -u -u -r1.2 var.m
--- 1.2	1997/09/27 14:54:19
+++ var.m	1997/09/27 18:12:05
@@ -109,7 +109,11 @@
 %
 %---------------------------------------------------------------------------%
 
-:- type var(T) ---> var_rep(var_rep(T))
+	% We use '$VAR'/1 as the name for the functor for variable
+	% representations simply because that name is "traditional".
+	% (Note that the representation can be printed out, if you call
+	% io__write(Var), so this is not entirely hidden from the user.)
+:- type var(T) ---> '$VAR'(var_rep(T))
 	where equality is (==).
 
 :- type var_rep(T)
@@ -241,11 +245,11 @@
 	ML_var_init_with_value(TypeInfo_for_T, Value, &Var);
 ").
 
-:- pred var__rep_init_with_value(T::in, var_rep(T)::out(var_rep_ground))
+:- pred var__rep_init_with_value(T::in, var_rep(T)::out(ptr(var_rep_ground)))
 	is det.
-:- pragma export(var__rep_init_with_value(in, out(var_rep_ground)),
+:- pragma export(var__rep_init_with_value(in, out(ptr(var_rep_ground))),
 	"ML_var_init_with_value").
-var__rep_init_with_value(Value, ground(Value)).
+var__rep_init_with_value(Value, alias(ground(Value))).
 
 :- pragma c_code( var(Value::out) = (Var::in) /* det */, may_call_mercury,
 "
-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list