|
I have been experimenting with adding generics support in Nemerle code emission engine. One could think that this should be an easy task in compiler already having parametric polymorphism. This is partially true, I don't have to touch typing engine too much, most of the information is already there. But on the other hand, there are still some blocking issues inside the compiler (informations which are not stored in program tree, because they were not used till now), and what is much more pain, in .NET frameworks we are using.
People are quite excited with lately released VS 2005 Beta2, but from the compiler perspective it doesn't bring too much. Literally all the bugs we have reported all over the last half year are still not fixed. That's ok, frameworks have bugs, in many they cases can be workarounded. But when we talk about generics... well, would you expect ToString or Equals methods to throw NotSupportedException? This is why I finally decided to move my experiments to Mono.
Of course live isn't easy here too. First I had to write methods recently added in MS.NET Beta2 in Mono BCL (unfortunately they are just quick hacks for my experiments, I didn't dig into mono S.R.E internals to create fully functional implementation). They are used to obtain members from instantiated generic type basing on member builders coming from noninstantiated type. For example consider
During compilation we have TypeBuilder representing G and MethodBuilder representing foo, we then want to obtain MethodInfo for G [int].foo, so we use TypeBuilder.GetMethod (instanciated, foo_method_builder). And with this thing everything seemed to go right with Mono, until I came into this. Well, I hope this won't be hard to fix, now I must deal with other issues inside Nemerle compiler anyways.
Summarizing, the smell of "fresh stuff" is still near generics in .NET, especially when we come into S.R.Emit API. But even with these issues I was able to make some progress. My current play-field already contains interesting stuff. Especially we can observe immediate advantage of using Nemerle type inference in working generic code like
compared to C#'s
Time will show how my experiment will progress into fully working solution. There is much chance that Nemerle will be the first bootstrapping compiler extensively using S.R.Emit to generate and utilize generics in the world (AFAIK gmcs isn't using generics for its own bootstrap).
BTW: We have a little Language Poll. Please stop by and give us some feedback about the tricky design decisions.
--Kamil