Subsections


Characters

All the symbols you can see on a computer, and some you cannot see, are known as characters. The alphabet consists of the characters A to Z and a to z. The digits comprise the characters 0 to 9. Every computer recognises a particular set of characters. The character set recognised by a68toc is ASCII (which stands for American Standard Code for Information Interchange). The mode of a character is CHAR (read “car” because it is short for character). A character is denoted by placing it between quote characters. Thus the denotation of the lower-case a is "a". Here are some character denotations:

   "a"  "A"  "3"  ";"  "\"  "'"  """"  " "

Note that quote characters are doubled in their denotations. The third denotation is "3". This value has mode CHAR. The denotation 3 has mode INT: the two values are quite distinct, and one is not a synonym for the other. The last denotation is that of the space character.

Here are some identity declarations for values of mode CHAR:

   CHAR a = "A", zed = "z";  CHAR tilde = "~"

Note that the two sets of identity declarations are separated by a semicolon, but the declaration for tilde is not followed by a semicolon. This is because the semicolon ; is not a terminator; it is an action. Identity declarations do not yield any value. An identity declaration is a phrase. Phrases are either identity declarations or units. When a phrase is elaborated, if it is a unit, it will yield a value. That is, after elaboration, a value will be available for further use if required. Again, this may not make much sense now, but it will become clearer as you learn the language.

Here is a piece of program with identity declarations for an INT and a CHAR:2.1

   INT ninety nine=99 , CHAR x = "X"

The compiler recognises 512 distinct values of mode CHAR, but most of them can only occur in denotations. The space is declared as blank in the standard prelude.


Exercises

1.8
Write the denotations for the full-stop, the comma and the digit 8 (not the integer 8). Ans[*]
1.9
Write a suitable identity declaration for the question mark. Ans[*]


Sian Mountbatten 2012-01-19