diff: remove univ_value/1

Fergus Henderson fjh at cs.mu.oz.au
Thu May 1 19:17:29 AEST 1997


library/std_util.m:
	Comment out `univ_value', since we can't implement it properly
	without existential types.

diff -u -r1.85 std_util.m
--- std_util.m	1997/04/30 07:54:48	1.85
+++ std_util.m	1997/05/01 09:11:08
@@ -61,8 +56,8 @@
 :- mode univ_to_type(out, in) is det.
 :- mode univ_to_type(uo, di) is det.
 
-	% The functions univ/1 and univ_value/1 provide equivalent
-	% functionality to type_to_univ/2 and univ_to_type/2.
+	% The function univ/1 provides the same
+	% functionality as type_to_univ/2.
 
 	% univ(Object) = Univ :- type_to_univ(Object, Univ).
 	%
@@ -71,11 +66,6 @@
 :- mode univ(di) = uo is det.
 :- mode univ(out) = in is semidet.
 
-	% univ_value(Univ) = Object :- univ_to_type(Univ, Object).
-	%
-:- func univ_value(univ) = T.
-:- mode univ_value(in) = out is semidet.
-
 	% univ_type(Univ):
 	%	returns the type_info for the type stored in `Univ'.
 	%
@@ -700,7 +665,23 @@
 
 univ(X) = Univ :- type_to_univ(X, Univ).
 
-univ_value(Univ) = X :- type_to_univ(X, Univ).
+/****
+
+% univ_value/1 can't be implemented yet, due to the lack of support for
+% existential types in Mercury.
+
+	% univ_value(Univ):
+	%	returns the value of the object stored in Univ.
+:- some [T] (
+   func univ_value(univ) = T
+).
+
+:- pragma c_code(univ_value(Univ::uo) = (Value), will_not_call_mercury, "
+	TypeInfo_for_T = field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO);
+	Value = field(mktag(0), Univ, UNIV_OFFSET_FOR_Data);
+").
+
+****/
 
 :- pragma c_header_code("
 

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