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

Tyson Dowd trd at cs.mu.OZ.AU
Sun Aug 23 15:39:19 AEST 1998


On 21-Aug-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > > 	TypeclassInfo_for_<fully-qualified classname>_<arity>__<var1>_<var2>
> > 
> > Nope.  What about
> > TypeclassInfo_for_class1_2__T1_T2_T3
> > 
> > is that
> > 	class1(T1_T2, T3)
> > or
> > 	class1(T1, T2_T3)
> 
> 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.

TypeclassInfo_for_2_foo__class1__T1___T2___T3

is that
	foo:class1(T1_, T2__T3)
or
	foo:class1(T1__T2_, T3)


If you convert all underscores to double underscores, and separate
variables with single underscores, you can use look for odd numbers of
underscores to find separators.  

TypeclassInfo_for_2_foo__class1__T1___T2____T3
				 T1_, T2__  T3
	
TypeclassInfo_for_2_foo__class1__T1____T2___T3
				 T1__  T2_, T3

TypeclassInfo_for_2_foo__class1__T1__T2_T3
				 T1_ T2,T3

TypeclassInfo_for_2_foo__class1__T1_T2__T3
				 T1,T2_ T3

Of course, now it's difficult for users to get it right.

-- 
Those who would give up essential liberty to purchase a little temporary
safety deserve neither liberty nor safety.     - Benjamin Franklin

Tyson Dowd   <tyson at tyse.net>   http://tyse.net



More information about the developers mailing list