8.1.1 How it works
The top level of the text only accepts units: named blocks that open and close. No executable statement may be left loose outside them.
A file with four sibling units one under the other: the constant SALUDO, the enumeration Color, the algorithm Tienda, highlighted as the only one, and the subroutine Precio.
| Unit | How many |
|---|---|
Algorithm | exactly one |
Subroutine, Function | as many as needed |
Class, Interface | as many as needed |
Record, Enumeration, Variant | as many as needed |
Constant | as many as needed |
Units are siblings: none goes inside another. They can be written before or after the algorithm, in any order.
ProgramAn algorithm with its neighbours
Constant SALUDO As String <- "Hola";
Enum Color
Rojo, Verde
EndEnum
Algorithm Tienda
Write SALUDO, " ", Precio(3);
EndAlgorithm
Subroutine Precio(unidades As Integer) As Integer
Return unidades * 5;
EndSubroutineOutput
Hola 15
The program finishes normally.
An empty algorithm is valid and does nothing. The algorithm's name does not take up the variable namespace: it may match the name of a variable.
8.1.2 Classic pseudocode
A program written in the classic style —Algorithm, Define with several names, Read, Write, If, Switch, loops, Dimension and Function with a result variable— is analysed without any diagnostic and runs as is, also from the terminal with pseudo ejecutar. The only requirements are the usual ones: semicolons, indices from zero and no variable read without a value.
In short
- A text has exactly one algorithm.
- Sibling units go around it, in any order.
- There are no loose statements or nested units.
- Classic pseudocode works without touch-ups.