naming-conventions - "Pascal Case"这个词是从哪里来的?

标签 naming-conventions pascal naming

一般来说,有四种常见的case styles .

  1. 驼峰式

  2. 小写

  3. 蛇形包

  4. 烤肉串

第一、第三和第四种风格的词源是微不足道的。但是第二个(即 PascalCase)呢?


根据 wikitionary ,

Etymology

Referring to the Pascal programming language.

链接只说

Letter case is ignored in Pascal source.


根据 Free Pascal wiki ,

Rules for identifiers:

  • Must begin with a letter from the English alphabet or an underscore (_).
  • Can be followed by alphanumeric characters (alphabetic characters and numerals), or the underscore (_).
  • May not contain special characters, such as: ~ ! @ # ...

(snip)

Pascal is not case sensitive! MyProgram, MYPROGRAM, and mYpRoGrAm are equivalent. But for readability purposes, it is a good idea to use meaningful capitalization!

There are two possible methods you could choose to apply to your identifiers: CamelCase and underscore as space. CamelCase, as it appears, means that separate words in an identifier are capitalized, so that you have newPerson or NewPerson instead of newperson. Using underscore as space means you separate words in an identifier with underscores, so that you have new_person instead of newperson. Or you could combine the two, so that you have new_Person or New_Person instead of newperson.

,这意味着不需要使用驼峰式标识符,例如 StackOverflowRedHatLinux


那么,“ Camel 案”这个词是怎么来的呢? Pascal 程序员是否首先开始使用 PascalCase 风格?

最佳答案

使用大小写将单词组合在一起的历史可以追溯到很久以前。

来自 Capitalize My Title :

CamelCase was primarily used in chemistry as a way to notate chemical compounds and formulas. In 1813, Berzelius, a Swedish chemist, suggested that the chemical elements should be represented consisting of one or two letters with the first one capitalized. The term used for this convention was medical capitals.

进入二十世纪:

In the early twentieth century, medical capitals used in Chemistry has been adopted in product trademarks and corporate names. However, the use is not yet prevalent. Some examples of these products include DryIce Corporation, CinemaScope, a widescreen movie format, MisterRogers, and VistaVision, among others.

在编程语言中:

Around the 1970s and 1980s, the use of medical capitals was also adopted as an alternative naming convention for identifiers in various programming languages. For instance, on the General Purpose Macro Processor (GPM) by Christopher Strachey, a program includes identifiers using medical capitals. These include “WriteSymbol,” and “NextCh.”

1990 年代后期:

By the late 1990s, the lower camel case became a popular trend in many brands. The lowercase for “i” which may stand for internet, information, or intelligent, and “e” which stands for electronic, became prefixes to various words. Examples of these words include eBay, iMac, eBox, and iPod.

驼峰命名法:

The term CamelCase only came into existence in the 1990s. Before that, the term medical capitals was commonly used. In April 1990, the term “InterCaps” was used by Avi Rappoport to describe the manner of capitalization. In 1991, Eric S. Raymond made mention of BiCapitalization to identify it.

It was not until 1995, however, that its current name was used. In a post by Newton Love, he mentioned that the humpiness of the style made him call it HumpyCase at first, before settling with CamelCase.

PascalCasing 名称的由来(来自 History around Pascal Casing and Camel Casing ):

In the initial design of the Framework we had hundreds of hours of debate about naming style. To facilitate these debates we coined a number of terms. With Anders Heilsberg (the original designer of Turbo Pascal) a key member of the design team, it is no wonder that we chose the term Pascal Casing for the casing style popularized by the Pascal programming language.

We were somewhat cute in using the term camelCasing for the casing style that looks something like the humps on a camel. We used the term SCREAMING CAPS to indicate an all upper case style. Luckily this style (and name) did not survive in the final guideline.


>Did pascal programmers first started using PascalCase style?

不,这是当时编程语言发展的普遍约定。


关于 Camel Case 的更多引用

关于naming-conventions - "Pascal Case"这个词是从哪里来的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60244301/

相关文章:

c++ - C++ 中的 int *x 和 int* x 有区别吗?

delphi - Pascal 中区分大小写(以 Integer 为例)

c - Pascal 的重复...直到与 C 的重复...而

delphi - 如何使用存储在 TList 中的对象的方法?

variables - 大范围函数变量的良好命名约定是什么?

java - 在 Java 中命名小型存储类

Android Activity 命名

reactjs - React 类名命名约定

nunit - 如何以编程方式访问 NUnit 测试名称?

Scala 类型别名命名规则?