Help - Language - Squeak Semi-formally - 3.2

Previous - Squeak Semi-formally - Next

3.2: Terms 2: Arrays

At this point we have defined the letters, digits, interpunctions and variable identifiers of the Squeak Language, but in fact have not yet introduced any wherewithal to do anything useful. This we start now, with arrays.

An array is a sequence of distinct components that can be stored and recalled as a unit by a computer. It occurs in most computer-languages, since it provides a basic way of storing and retrieving information. 

array = "(" [number | symbol | string | character_constant | array]* ")".

Thus an array is written as a bracketed  sequence of items, that may in general be about anything, including arrays. One main limitation on arrays, also in Squeak, is that they must be pre-declared and have a fixed length. A nice thing about the notation for arrays in Squeak is that the separator used is not the comma, as in most languages, but the empty character. This is easier to read, especially in long arrays.

Next, often the most convenient thing to store something in  computer-memory is in an array of constants. In Squeak, this is defined with help of the following term:

literal = (number | symbol_constant | character_constant | string | array_constant).

The literals consist of those items that are constants for Squeak. These are used in the next definition:

array_constant = "#" array of literals

Here we see a convention at work in the previous section, namely the use of the prefix "#" to  indicate that the  rest of the string following it is a symbol and so a constant. 

Previous - Squeak Semi-formally - Next