Extension Methods - Nice. but not sufficient

I am going to do a longer posting on problems of extending value types, but since I just had to complain on Connect after bumping into the decision not to support operators as extension methods, I had to complain now.  In essence, the restriction on .net not to allow any subclassing of value types is not a good thing, Vector3D being an exceptionally nasty glaring example of the problems this can cause……..

Here’s what I said

I think you need to review this sooner, rather than later due to an unfortunate interaction with another .net rule

You can't subclass a value type -  and there are a number of critical value types, such as Vector3D in WPF that desparately need this -  this isn't to say the WPF team did a bad job, just that the number of functions and operators applied to these elements is _huge_, and there's no way they're ever going to be able to make everyone happy - and creating an aggregating class is a poor choice, cause its ugly, and worse, inefficient

That said, WPF doesn't know how to multiply 2 Vector3D instances together, much less multiply a vector and a scalar -  the real improvement would be to fix the language, i.e. to allow subclassing of value types by addition of logic only, but failing that. we really really need to be able to add operators as extension methods. please......

Tags:
Published Monday, October 15, 2007 9:18 PM by MarkMMullin
Filed Under: ,

Comments