[Mono-devel-list] sharing generic instantitions

Michal Moskal michal.moskal at gmail.com
Sat Jul 2 08:50:50 EDT 2005


As far as I know the MS implementation of generics uses sharing of
code in certain situations. For example if we have a method foo<T>()
the code for foo<object>() and foo<string>() will be shared. However
the code for foo<int>() and foo<double>() will probably not be shared,
because the sizes of int and double are different.

There is a problem, when you use the type parameter, for instance
foo<T> () { ... new Hashtable <T,int> () ... }. You need to know its
value, so it has to be actually passed, just like a regular parameter.

This is explained in more detail here:


Is this feature planned in Mono?

This is mostly a performance issue. I don't know how bad could be the
impact of lack of this feature, because of:


but as far as I can see in the Nemerle compiler, using highly generic code
the amount of generated code is 3x as big as with version using boxing
everything to object.

   Michal Moskal,

More information about the Mono-devel-list mailing list