Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

0

近期,Python语言因引入了一种被认为影响阅读理解的表达方式而引发热议。这种表达方式是”a*=3″,它的作用是使变量a的值等于2倍于它当前的值再乘以3。尽管它的计算结果是正确的(a最终等于6),但是人们普遍认为这种方式不利于阅读理解。

许多人对此表示不解,因为将这个表达式写成”a=a*3″似乎更自然且易于理解。有人认为,Python引入这种表达方式的初衷是为了减少一个字符的输入,但这种做法可能会对代码的可读性产生负面影响。

实际上,这种争论并非首次出现。在计算机编程的历史中,类似的争议一直存在。例如,有些人认为使用”a++”比”a=a+1″更好,因为它更简洁;然而,另一些人则认为前者更容易引起误解。类似地,这种关于”a*=3″的争论也可能没有明确的答案。

尽管如此,编程语言的设计者们应该考虑到程序员的需求和经验。他们需要找到一种既能满足代码效率需求又能保持代码可读性的平衡点。在这种情况下,或许应该让程序员自行决定哪种表达方式更适合他们的项目。毕竟,每种编程语言的语法都是经过多年演变而来的,而且每个开发者都有其自己的习惯和偏好。

【来源】https://www.zhihu.com/question/620535557

Views: 2

0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注