gpt4 book ai didi

vb6 - 为什么短路不是 VB 中的默认行为?

转载 作者:行者123 更新时间:2023-12-03 20:28:23 25 4
gpt4 key购买 nike

VB有运营商AndAlsoOrElse , 执行 短路逻辑连词。

为什么这不是 的默认行为和 表达式,因为短路在任何情况下都是有用的。

奇怪的是,这是相反到大多数语言 && || 进行短路。

最佳答案

因为 VB 团队必须保持与旧代码(和程序员!)的向后兼容性

如果短路是默认行为,按位编译器会错误地解释操作。

The Ballad of AndAlso and OrElse由 Panopticon Central 提供

Our first thought was that logical operations are much more common than bitwise operations, so we should make And and Or be logical operators and add new bitwise operators named BitAnd, BitOr, BitXor and BitNot (the last two being for completeness). However, during one of the betas it became obvious that this was a pretty bad idea. A VB user who forgets that the new operators exist and uses And when he means BitAnd and Or when he means BitOr would get code that compiles but produces "bad" results.

关于vb6 - 为什么短路不是 VB 中的默认行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/486722/

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