5.4.1 How it works
Not everything that can be read can be written. x + 1 has a value, but it is not a place: there is nowhere to store anything. Statements that store values —assignment, Read and passing by reference— require a designator.
On the left, three designators: x, notas[i] and persona.nombre. On the right, three expressions that are not: 5, x + 1 and length(t).
| Is a designator | Is not a designator |
|---|---|
x | 5 |
notas[i] | x + 1 |
persona.nombre | Longitud(t) |
tabla[i, j] | (x) |
The indices and the receiver of a designator are evaluated only once, before storing:
ProgramCells as targets
Algorithm Designadores
Dimension notas[3] As Integer;
Define i As Integer <- 0;
notas[0] <- 7;
notas[i + 1] <- notas[0] + 1;
notas[2] <- 10;
Write notas[0], " ", notas[1], " ", notas[2];
EndAlgorithmOutput
7 8 10
The program finishes normally.
In notas[i + 1] the index is any expression, but notas[…] as a whole still names a place.
In short
- A designator names a place: variable, cell or attribute.
- Assigning,
Readand passing by reference require a designator. - Literals, operations, calls and parentheses are not designators.