Case Sensitivity

The appearance of congruency fails under scrutiny

CSP is case sensitive. This means that uppercase and lowercase letters are considered different characters. DISPLAY and display are not the same thing to CSP, and neither are age and Age.

Keywords

Built-in words such as DISPLAY, IF, ELSE, MOD, AND, OR, and NOT must be written in all uppercase letters.

Keyword (noun)
Words built into a language that define special behavior
A built-in word like IF or DISPLAY
csp
You may also type <- !=>= <= for auto complete.

Writing display("This does not.") is an error, because CSP does not recognize display as the command we meant. The same is true of if, mod, and, and every other keyword.

csp
You may also type <- !=>= <= for auto complete.

The booleans are the opposite. They must be written in all lowercase letters. true and false are values, but TRUE and False are not.

csp
You may also type <- !=>= <= for auto complete.

Variables

Variable names are case sensitive too. Each of the names below is its own separate variable.

csp
You may also type <- !=>= <= for auto complete.

This displays 1, 2, and 3. Because it is easy to mix these up, it is best to pick one style and stick with it. In this book, variable names start with a lowercase letter, and a name made of several words capitalizes each word after the first, like isFinished or totalScore.

A misspelled capital is a common source of bugs. If we create totalScore but later type totalscore, CSP sees a name that was never created.

Strings

The text inside a string is case sensitive as well. "Hello" and "hello" are different values, so comparing them with = gives false.

csp
You may also type <- !=>= <= for auto complete.

The first display shows true and the second displays false. Keep this in mind whenever a program compares text typed by a user.

Not every language works this way. Fortran is case insensitive, so PRINT, print, and Print are all the same command, and the variables total and TOTAL are the same variable. See an example below.

fortran
You may also type <- !=>= <= for auto complete.

This program prints 6, because all three spellings of total refer to one variable. Text inside a Fortran string is still case sensitive, just like in CSP.

Most popular languages, including Python, JavaScript, Java, C, C++, C#, and Rust, are case sensitive like CSP. Fortran and SQL keywords are common exceptions. You can read more about the idea in general on the case sensitivity page.


Next: Lists & For Each