I am trying to write a generic type Vector2 that will contain types float, double, etc. and use arithmetic operations. Is there any way to do this in C #, F #, Nemerle, or any other more or less mature .NET language?
I need a solution with
- (1) good performance (the same thing that I would write separately Vector2Float, Vector2Double, etc.),
- (2) which would allow the code to look good (I don't want to allocate code for each class at runtime)
- (3) and which will do as much compilation time as possible.
For reasons 1 and 3, I would not want to use dynamics. Now I am checking out F # and Nemerle.
UPD: I expect that I will have a lot of math code for this type. However, I would prefer to put the code in extension methods, if possible.
UPD2: etc. include int (which I really doubt that I will use) and decimal (I think I can use, but not now). Using extension methods is just a matter of taste - if there are good reasons not to, please let me know.
source
share