为什么存在这些替代运算符表示形式 [英] Why do these alternative operator representations exist

查看:43
本文介绍了为什么存在这些替代运算符表示形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这些替代的运算符表示形式:(摘自此处)

Consider these alternative operator representations: (taken from here)

Primary Alternative
&&      and
&=      and_eq
&       bitand
|       bitor
~       compl
!       not
!=      not_eq
||      or
|=      or_eq
^       xor
^=      xor_eq

为什么这些替代的运算符表示形式存在?我喜欢它们,但我试图找到理由让我的经理允许我使用它们.

Why do these alternative operator representations exist? I like them but I am trying to find reasons to give to my manager to allow me to use them.

推荐答案

正如tomislav-maric在评论中指出的,原因恰恰是您引用的页面上给出的内容:一些较旧的普遍编码不包含被替换的字符.这是可能今天不是很相关,因为这些编码具有几乎消失了,取而代之的是一些ISO 8859编码或UTF-8.我认为您不能将其用作为您的经理辩护.

As tomislav-maric points out in a comment, the reason is exactly that given on the page you cite: some older widespread encodings didn't contain the characters which are replaced. This is probably not very relevant today, since those encodings have pretty much disappeared, being replaced by some of the ISO 8859 encodings or UTF-8. I don't think you can use this as an argument for your manager.

另一方面,至少某些C ++专家更喜欢或和 not 替换为& || !我不是其中之一,但在那里无论哪种方式都是论据.我的感觉仅仅是它是C/C ++,还有很多奇怪的字符序列规则.(如果我从头开始设计一种语言……)

On the other hand, at least some C++ experts prefer and, or and not to &&, || and !. I'm not one of them, but there are arguments either way. My feeling is simply that it's C/C++, and lots of strange character sequences rule. (If I were designing a language from scratch, however...)

关于页面下方的三部曲:被认为是没有真正效果的实验.据,直到...为止我知道,没有人真正使用过它们.结果代码将就像替换字符一样不可读用过的.如果您使用的是德语,请考虑其他选择ISO 646:

With regards to the trigraphs lower down on the page: that can be considered an experiment that didn't really work. As far as I know, no one ever really used them; the resulting code would be just as unreadable as if the replacement characters were used. Consider the alternatives if you were using the German ISO 646:

int arrayÄ 10 Ü;      //  native
int array??( 10 ??);  //  tri-graphs
int array<: 10 :>;    //  digraph

只有最后一个甚至有点可读性,但是到那时指定了最后一个,问题几乎消失了.

Only the last is even slightly readable, but by the time the last was specified, the problem had pretty much disappeared.

另外一点.无论个人喜好,您应该做出决定 and / or / not && / || /在团队级别,团队中的每个人都应该使用相同的惯例.

One additional point. Regardless of personal preferences, you should make the decision and/or/not vs. &&/||/! at a team level, and everyone in the team should use the same conventions.

FWIW:三字母组合最初是在C90中引入的(K& R C没有他们);C ++ 98和C99中的有向图和备用标记.(我不是立即确定是否支持较早版本的CFront还是不行.)

FWIW: trigraphs were first introduced in C90 (K&R C didn't have them); digraphs and alternate tokens in C++98 and C99. (I'm not sure offhand whether the earlier versions of CFront supported them or not.)

这篇关于为什么存在这些替代运算符表示形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆