Tuesday, October 31, 2006

Things I'm missing in C#/CLR

Although C# is a great language, I'm still missing some features. I know it's mostly a matter of CLR limitations, but I'm missing it nonetheless.

  1. Signature-free Delegate - imagine you have a system that works intensively with configuration/settings files, loading stuff at runtime. Now you want this system to be able to dynamically receive a delegate from one source and parameters from another source, and run that delegate with those parameters. At compile time, the only thing you know is that you have to run some delegate - you don't know its signature. I'd like a way to define a delegate that accepts any signature, and a technique to dynamically call it with whatever parameters I get. Of course it means that important stuff cannot be checked at compile time, but sometimes it's the best way to provide a generic solution (if you're interested, I could post an example of what I mean in some later post).
  2. Multiple Inheritance - I know, this is almost a theological issue (much like the Good/Bad Agile debate going on lately). I also admit that it doesn't happen a lot that I really need multiple inheritance. Yet, sometimes I do, and at these times, I'm really p'd off for not having the option (and don't give me the brainwashed crap feeded by Microsoft that you never need it and can always use some pattern to work around it!). BTW - Eiffel.NET has full multiple inheritance support.
  3. Method Signatures - as in C++, methods can't differ only by return type. That sucks, plain and simple.
  4. Multiple Return Parameters - who said a method must return only one parameter? If I want to divide two numbers and get both the integer result and the remainder - why do I need to get one in the return value and the other as an "out" argument?
  5. Interactive Scripting - I've written enough about that.


Ayende Rahien said...

1/ delegate(params object[] args)
2/ Yes, I really wants this!
3/ Don't really agree here. It REALLY affects readability of code.
4/ Multiply return values would be cool, though.

Ilan Assayag said...

1) And how would you call it? Maybe there is something I don't know, but how can you give such a function an array, and make sure it will take each element of the array as a separate argument (as opposed to using the whole array as one single argument)? Also, I'm a real nudnik, and want it to avoid boxing/unboxing in case of primitives.
3) Simple example - all the Math.XXX function, that return only double variables and must be casted. If I call:
int num = Math.Ceil(...);
then I want it to work without needing to cast it.