Skip to content

SpecificationV · Declarations and statements

5.4

Designators

A designator is something that names a place where a value can be stored: a variable, an array cell or an attribute of an object.

Markdown version

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.

Figure 5.4-1.On the left, designators: they name a place. On the right, expressions that only have a value.

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 designatorIs not a designator
x5
notas[i]x + 1
persona.nombreLongitud(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];
EndAlgorithm

Output

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, Read and passing by reference require a designator.
  • Literals, operations, calls and parentheses are not designators.