[m-dev.] diff: pass typeclass-info args to C code

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 24 02:04:16 AEST 1998


On 21-Aug-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> If type var names are not allowed to have __ inside of them, or if any
> __'s are converted to ___'s, the following scheme is guaranteed to work:
> 
> TypeclassInfo_for_<arity>_<fully-qualified classname>__<var1>__<var2>
> 
> The arity is unambiguous, and one can uniquely determine where the class name
> ends by counting __'s from the back.

Any scheme which includes double underscores in the middle of the name
won't work for the C++ interface, since C++ reserves all such names.
It would be confusing if the C interface was different from the C++
interface it this respect, so I suggest we avoid double underscores.

Also, typing out the arity and the fully qualified class name
is going to be tedious for the programmer (remember the programmer
may need to use these names in the C/C++ code fragment).

I suggest instead using just

	TypeclassInfo_for_classname_1
	TypeclassInfo_for_classname_2
	TypeclassInfo_for_classname_3
	etc.

for the 1st, 2nd, 3rd, etc. occurrence of each type class constraint in the
pred's type declaration.

E.g. for

	:- pred foo(T1, T2) <= bar(T1), bar(T2),
				othermod:bar(T1, T2), baz(T1).

the type_info variables would be named
	
	TypeclassInfo_for_bar_1
	TypeclassInfo_for_bar_2
	TypeclassInfo_for_bar_3
	TypeclassInfo_for_baz_1

Or alternatively perhaps the same but without the `_1's
(i.e. only the second and subsequent occurrences get the numerical
suffix).

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