[m-dev.] Re: Documentation of support for polymorphic pragma c code

Oliver Hutchison ohutch at students.cs.mu.OZ.AU
Thu Jan 15 14:01:05 AEDT 1998


On Wed, 14 Jan 1998, Fergus Henderson wrote:

> Quick poll: now that we've explored the options a bit, who prefers what? 
> Which of the following do you think would be the most elegant design?
> 
> 	1. using `TypeInfo_for_T'	(implementation status quo)
> 	2. using `type_of(Var)'		(documentation status quo)
> 	3. using `MR_TYPE_INFO(Var)	(Peter Schachte's suggestion)
> 

Using `TypeInfo_for_T' and `MR_TYPE_INFO(Var)' are essentially the same,
but the advantages that Fergus mention with regard to name space
invasion/higher level of abstraction probably put Peters suggestion on top
of using `TypeInfo_for_T'.

I still don't really like the use of wrappers but once type_of/1 becomes a
builtin my only objection to using `type_of(Var)' would have to be
aesthetic.

Perhaps another option would be to somehow let the programmer specify the
names for variables that will be used to hold the typeinfos? Something
like this : 


:- pred fug(T).
:- mode fug(in) is det.

:- pragma c_code(fug(V::in), type_info(T, TypeInfo_for_T), "
	do_some_stuff(T, TypeInfo_for_T);
").


This way only the type infos that get used need to be created and the
others can be removed by unused args. One possible extension of this would
be to let the user specify a variable instead of a type variable. This
would allow any pragma c_code the get the type infos of its arguments
regardless of whether it is mono or polymorphic. 

Given what I have written above about allowing monomorphic pragma c_code
to get access to type infos. I guess I would have to say that the
`type_of(Var)' method is the best simply because currently that method
would be the only one of the three that can be used to get typeinfos for
both mono and polymorphic pragma c_code.  



	Oliver





More information about the developers mailing list