为什么逻辑运算符的书面版本不会更广泛地使用? [英] Why are the written versions of logical operators not more widely used?

查看:177
本文介绍了为什么逻辑运算符的书面版本不会更广泛地使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么逻辑运算符的书写版本没有更广泛地使用?我知道为什么它们存在(为了消除与编程早期的QWERTY键盘相关的问题),但它们似乎是一个语法糖否则丑陋的运算符。在 auto 和基于范围的for-loops的这一天,当 c> 或。



<对于开始 C ++ 学生比&& 更直观。同样,等效于 ||



我找到了 this 答案,特别是以下blockquote启发:


...至于他们的使用:因为它们很少使用,所以使用它们通常更令人惊讶和混乱, 。我相信如果它是正常的,他们会更容易阅读,但人们是如此习惯&&和||


这基本上对我说人们不使用他们,所以他们不期望他们,这似乎很奇怪,因为(至少对我来说)比使用&& 更直观。

解决方案

我使用它们,我敦促人们也使用它们。这真的是所有的。几个人使用它们的原因是(a)历史和(b)Visual C ++不能识别它们,并且要求用户包括< ciso646> 这是一个错误这是Microsoft认可但拒绝修复。



这真的是所有关于他们。


Why are the written versions of the logical operators not more widely used? I understand why they exist (to eliminate problems associated with QWERTY keyboards in the early days of programming), but they seem like a syntactic sugar to otherwise "ugly" operators. In this day of auto and range based for-loops, it seems counter intuitive to use a an "ugly" operator when and and or are available.

Surely and is more intuitive to a beginning C++ student than &&. Likewise with or being equivalent to ||.

I've found this answer, particularly the following blockquote enlightening:

...As for their use: because they are rarely used, using them is often more surprising and confusing than it is helpful. I'm sure if it were normal, they would be much easier to read, but people are so used to && and || anything else just gets distracting.

Which basically says to me "people don't use them so they don't expect them", which seems strange to be because and (to me, at least) is more intuitive than using &&.

解决方案

I use them, and I urge people to use them, too. That’s really all there is to it. The reason for few people using them is (a) historical and (b) Visual C++ does not recognise them, and requires the user to include <ciso646>. That’s a bug which Microsoft recognises but refuses to fix.

That’s really all there is to say about them.

这篇关于为什么逻辑运算符的书面版本不会更广泛地使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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