开发者

Will using of non CLS compliant types in a language which doesn't support unsigned cause issue?

My case is:

I'm working a .net library 开发者_Go百科which wraps an existing C++ library. One method in C++ returns an unsigned int and I also want to return the .net corresponding method with an System.Uint32.

Will this cause some issue for languages which don't support unsigned data types?


Most probably there will be issues (especially when you return numbers which are greater than 2^31), but according to this SO post

Are there languages compatible with .NET that don't support unsigned types?

it seems there are not many .NET languages (or, no important ones, though importance may be subjective) which don't support unsigned data types.


If a class is legitimately CLS compliant, the only features one should require languages to support things beyond the CLS minimum requirements would be those which would be meaningless in the absence of such features. For example, a CLS-compliant method group may include overloads for unsigned integer types if any functionality provided by those methods would be available via other means.

If a class is supposed to do something like provide a means of reading and writing unsigned 32-bit values from some external data set, CLS compliance would not forbid the type from providing methods that read and write data of type UInt32, but would require that any data which could be read or written via such methods must be readable by other methods that do not require that type [e.g. they could use Int64 instead]. Client code which uses Int64 might less efficient than would be code using UInt32, but the failure of a language to support UInt32 wouldn't prevent the client code from doing what it needs to do--it would merely slow it down slightly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜