Sfairadora

  • Reference Guide

Structure

Structure is a compound type consisting of a predetermined fixed number of components. Every component has its own type (scalar or compound again). The types of individual components may differ. The components are distinguished by names. Component names must be identifiers.
Components may be marked as optional – in that case they need not be present in the instance.
Further, it is possible to predefine the initial value of every component. When a structure instance is created, the component acquires the predefined value unless another value is explicitly specified. If the initial value is not defined, the initial value appropriate for the component type is used (e.g. 0 for numbers, an empty string for strings, etc.).
The purpose of a structure is to combine data items, related by meaning, into one unit so that the user can manipulate them as if they were one item (copy or compare them in a single operation etc.).

Notation

Struct(Type1 name1, Type2 name2,...)

Example

A structure of basic personal data:
Struct(String first_name,
String last_name,
Int age)