What I cannot do with generics ?

I am still trying to understand the full benefits of generics. I picked up the following that you cannot do with Java generics from the Sun generics forum where sometime back a generics debate was raging.

Use constants.
Cannot perform compile-time recursion.
Cannot do compile-time loop unrolling.
Cannot create full or partial specializations.
Cannot work with primitive types.
Cannot create arrays of generic types.
Cannot check generic casts at compile time.
Cannot do type analysis at compile time.
Cannot do anything with generics that would create multiple instantiations of the generic code.
Though I am not a C++ programmer, I found this article http://www.langer.camelot.de/Articles/Cuj/ExpressionTemplates/ExpressionTemplates.htm that would support many of the above points. It looks like a serious drawback of the Java implementation of generics.

  It would be interesting to check how many of the above are possible using C#.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: