Help - Language - Squeak Semi-formally- 3.1

Previous - Squeak Semi-formally - Next

3.1 Terms 1: Variable Identifiers of various kinds

Sofar in fact we considered the smallest well-formed expressions in Squeak: characters, digits and interpunction. Terms of a language are well-formed expressions that are intermediate between characters and statements, and that have some sort of meaning on their own. In English what are called "terms" here are often also called "words" or "phrases".

In Squeak, most of the terms are called "identifiers", which is a fancy name for "name". There are several kinds of them. In this section I deal with the various kinds of variable identifiers in Squeak, used for different purposes in different contexts, which the user may introduce for his own ends:

identifier = letter [letter | decimal_digit]*.

This defines the general set of identifiers: Any string that is made up of letters or decimal_digits (and so without whitespace etc.). Likewise there is in Squeak:

capital_identifier = uppercase [letter | decimal_digit]*.

This is just like an identifier, except that it starts definitely with an uppercase letter. Squeak has both of them because of its convention (chosen but not imposed by the Squeak parser, in most cases) to have capital_identifiers for common names (names for possibly many things) and other identifiers for individual names (names for precisely one thing).

Next, there are in Squeak two explicit ways to mark special terms:

character_constant = "$"(character | "'" | """).


symbol_constant = "#" symbol.

The character-constants exist, among other things, to be able to deal with terms like "+" without making Squeak regard them as instructions to add. 

The symbol_constants exist, among other things, to make sure that Squeak treats the identifier that follows "#" as a unique name in the system, and is used everywhere in its code to name parts of it. What is a "symbol" in Squeak is defined below:

symbol = identifier | binary_selector | [keyword]+ | string.

"Binary_selector" and "keyword" are defined further down, and "string" immediately below. The general point of symbols in Squeak (as in many other computer-languages) is to have unique names for things in the system.

One important point to notice (that may differ from conventions in other languages) is that for Squeak a string is in fact a symbol and so a kind of complex constant.  Strings are explicitly defined as follows:

string = "'" [character | "'" "'" | """]* "'".

The point of this definition is that a string is a sequence of characters possibly with comments before, inside and after it (and comments are very useful inside programming code, to explain what happens and may be problematic).

Previous - Squeak Semi-formally - Next