[m-rev.] diff: tuples deconstruct implementation

Peter Ross pro at missioncriticalit.com
Sat Nov 30 01:32:37 AEDT 2002


Hi,

I have one concern with this change, and that is to do with the behaviour
of type_ctor_and_args.

If one looks at the code for deconstructing du types, you will see that it
jumps through many hoops to find the type_info for each argument.  I am
not clear why that all needs to be done.  Could for instance that code
be rewritten to use type_ctor_and_args instead?

I will check this simple version of the change in, but am looking forward
to enlightenment on the mysteries of the runtime system.

===================================================================


Estimated hours taken: 2
Branches: main


library/rtti_implementation.m:
	Implement tuple deconstruction.

Index: rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.29
diff -u -r1.29 rtti_implementation.m
--- rtti_implementation.m	29 Nov 2002 13:56:29 -0000	1.29
+++ rtti_implementation.m	29 Nov 2002 14:07:23 -0000
@@ -764,9 +764,15 @@
 		Arguments = []
 	;
 		TypeCtorRep = tuple,
-		Functor = "some_tuple", 
-		Arity = 0,
-		Arguments = []
+		type_ctor_and_args(TypeInfo, _TypeCtorInfo, TypeArgs),
+		Functor = "{}", 
+		Arity = get_var_arity_typeinfo_arity(TypeInfo),
+		list__map_foldl(
+			(pred(TI::in, U::out, Index::in, Next::out) is det :-
+				SubTerm = get_subterm(TI, Term, Index, 0),
+				U = std_util__univ(SubTerm),
+				Next = Index + 1
+			), TypeArgs, Arguments, 0, _)
 	;
 		TypeCtorRep = univ,
 		Functor = "some_univ", 

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