.Net generics are great. Of course. Typing them is a pain. Even in C# where the Intellisense is very good, it is tedious to make the type names so long, especially when doing a lot of data type composition, like this (or worse):
Dictionary<int, Dictionary<String, KeyValuePair<MethodInfo, MyCustomMethodAttribute>>>
Grok that. Easy? Now feast your eyes on this:
Dictionary<int, Dictionary<String^, KeyValuePair<MethodInfo^, MyCustomMethodAttribute^>>^>^
In C++/CLI, you need the hats (managed pointers) to refer to reference handles (as opposed to value types like KeyValuePair, which don’t use the hat). It’s easy to get confused (does the hat disappear between the 2nd or 3rd to last right angle bracket?) when coding fast and furious.
In C#, you can subclass a generic type like this:
public class MethodTable : Dictionary<int, Dictionary<String, KeyValuePair<MethodInfo, MyCustomMethodAttribute>>> {}
So, now you can use this class in place of the unwieldy generic type. In C++, you can also do this:
#define MethodTable Dictionary<int, Dictionary<String^, KeyValuePair<MethodInfo^, MyCustomMethodAttribute^>>^>^
This doesn’t define a new type, just gives you some compile time syntax sugar. I prefer the latter, since C++/CLI already creates so many types for IJW, I don’t like to add more.
I can see how C++ macros are easily abused to create whole sub-languages in a program. I’m already going down that path.