[m-dev.] Re: Documentation of support for polymorphic pragma c code
Peter Schachte
pets at students.cs.mu.oz.au
Wed Jan 14 14:25:55 AEDT 1998
On Wed, 14 Jan 1998, Oliver Hutchison wrote:
> :- pred fug(T1, T2).
> :- mode fug(in, out) is det.
>
> fug(A, B) :-
> TypeInfo_for_T1 = type_of(A),
> TypeInfo_for_T2 = type_of(B),
> fug2(TypeInfo_for_T1, TypeInfo_for_T2, A, B).
>
> :- pred fug2(type_info, type_info, T1, T2).
> :- mode fug2(in, in, in, out).
>
> :- pragma c_code(fug2(TypeInfo_for_T1::in, TypeInfo_for_T2::in, A::in,
> B::in), "
> do_some_stuff(TypeInfo_for_T1, TypeInfo_for_T2, A, B);
> ").
>
>
> could be written
>
> :- pred fug(T1, T2).
> :- mode fug(in, out) is det.
>
> :- pragma c_code(fug(A::in, B::in) ,"
> do_some_stuff(TypeInfo_for_T1, TypeInfo_for_T2, A, B);
> ").
>
>
> I know I like the second alternative.
The (well, one) trouble with documenting this is that it puts the way type
infos are handled into the language. I really don't think it belongs there.
I guess the following would be quite horrible to try to implement, but I'd
really like to write something like this:
:- pred fug(T1, T2).
:- mode fug(in, out) is det.
:- pragma c_code(fug(A::in, B::in) ,"
do_some_stuff(MR_TYPE_INFO(T1,1), MR_TYPE_INFO(T2,1), A, B);
").
(The second argument to MR_TYPE_INFO being the parameter number of the type
of the first argument, needed for multiparametric types).
-Peter Schachte | The wrong sort of people are always in power
pets at cs.mu.OZ.AU | because they would not be in power if they
http://www.cs.mu.oz.au/~pets/ | were not the wrong sort of people. -- Jon
PGP key available on request | Wynne-Tyson
More information about the developers
mailing list