gpt4 book ai didi

c# - 为什么 unsigned int 不符合 CLS?

转载 作者:IT王子 更新时间:2023-10-29 03:35:44 26 4
gpt4 key购买 nike

为什么无符号整数不符合 CLS?

我开始认为类型规范只是为了性能而不是为了正确性。

最佳答案

并非所有语言都有无符号整数的概念。例如,VB 6 没有无符号整数的概念,我怀疑这促使 VB7/7.1 的设计者决定不实现它(它现在在 VB8 中实现)。

引用:

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

The CLS was designed to be large enough to include the languageconstructs that are commonly needed by developers, yet small enoughthat most languages are able to support it. In addition, any languageconstruct that makes it impossible to rapidly verify the type safetyof code was excluded from the CLS so that all CLS-compliant languagescan produce verifiable code if they choose to do so.

更新:几年前我确实想知道这个问题,虽然我不明白为什么 UInt 不能进行类型安全验证,但我猜 CLS 的人必须在某个地方有一个分界点是什么支持的值类型的基线最小数量。此外,当您考虑从长远来看越来越多的语言被移植到 CLR 时,如果绝对没有概念,为什么要强制他们实现无符号整数以获得 CLS 合规性?

关于c# - 为什么 unsigned int 不符合 CLS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6325/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com