Rust 的设计者选择符号 !/&&/|| 的原因是什么?而不是单词 not/and/or?

What is the reason that the designers of Rust chose the symbols !/&&/|| instead of the words not/and/or?

选择运算符 !/&&/|| 而不是 not/and/or 的理由是什么?它背后有什么历史,还是只是一种偏好?

我的一些想法:

由于 Rust 是一种新语言,我认为他们可以毫无问题地选择符号或单词。 Rust 选择符号而不是文字的原因是什么?为什么两者都不选?

早在 2006 年,Graydon Hoare 就作为一个小项目开始研究 Rust。 Hoare 还从事 Servo 浏览器引擎方面的工作。他对 Rust 的目标是它可能有助于开发所述浏览器引擎。由于该引擎(与几乎所有其他浏览器引擎一样)当时是用 C++ 编写的,因此 Rust 基本上是 Hoare 的 C++ 替代品。

所以使用与 C++ 相同的逻辑运算符似乎很自然。

2010 年创建 GitHub 存储库时,&&|| 已经使用 Rust 语言。见 the lazy-and-or.rs test during the second commit in the repository:

if (true && x) { ... }

随着时间的推移,语言设计过程变得更加民主,并且出现了更多的想法。但直到 2016 年 someone officially proposed adding not, and and or as an RFC.

但是如您所见,RFC 已关闭。贡献者withoutboats是这样解释的:

If I were designing a language from the beginning, I would probably prefer and and or. But we are generally opposed to contextual keywords unless absolutely necessary, contextual keywords in expression contexts are particularly difficult to introduce, and we tend to avoid syntactic sugar of the "pick your poison" variety.

重要的是,那时 !&&|| 已经稳定了一年多。因此,唯一的选择是添加替代运算符,而不是替换那些运算符。那似乎不值得。


免责声明:我在 2014 年才加入 Rust 社区。在 IRC 或我无法搜索到的其他媒体中可能有关于此的更大讨论。但我能找到的就这些了。