tags:

views:

1859

answers:

5

Why are unsigned int's not CLS compliant. I start to think type-specification is just for performance, and not for correctness.

+29  A: 

Not all languages have the concept of unsigned ints. For example VB 6 had no concept of unsigned ints which I suspect drove the decision of the designers of VB7/7.1 not to implement as well (it's implemented now in VB8).

To quote -

http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx

"The CLS was designed to be large enough to include the language constructs that are commonly needed by developers, yet small enough that most languages are able to support it. In addition, any language construct that makes it impossible to rapidly verify the type safety of code was excluded from the CLS so that all CLS-compliant languages can produce verifiable code if they choose to do so."

Update: I did wonder about this some years back, and whilst I can't see why a UInt wouldn't be type safety verifiable, I guess the CLS guys had to have a cut off point somewhere as to what would be the baseline minimum number of value types supported. Also when you think about the longer term where more and more languages are being ported to the CLR why force them to implement unsigned ints to gain CLS compliance if there is absolutely no concept, ever?

Kev
+1. Fantatic answer. Thanks. 18 months later, too :-)
James Wiseman
+1  A: 

Unsigned integers are not CLS compliant because they're not interoperable between certain languages.

Bryan Roth
A: 

@Kevin: I just wondered about the topic. You answer seems logic. I just like to think about the topic. I think it's a shame Pascal-like types didn't make it into the CLR. But your argument about other languages: that didn't stop IronPython using strongly dynamic typing (DLR) in an stongly static typed CLR?

doekman
A: 

@doekman: Whilst yes IronPython and IronRuby demonstrates that the CLR can provide a platform onto which you can build dynamically typed languages, the goal of the CLS was to provide a set of standards that transcend language functionality and allow them to interoperate sucessfully and safely.

I don't think what a language can do in terms of say adding DL features is directly related to the what should go into the CLS/CTS.

Kev
+1  A: 

Unsigned int's don't gain you that much in real life, however having more than 1 type of int gives you pain, so a lot of languages only have singed ints.

CLS compliant is aimed at allowing a class to be made use of from lots of languages…

Ian Ringrose