t3x.org / t3x / t3x-manual / 244.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
2.4.3 Vectors
TOC | Index | Back Next:
2.5 Factors

2.4.4 Structures

A structure is a composed data object. Only one structure may be defined in a single STRUCT statement:

STRUCT POINT = PT_x, PT_y;

Such a statement does not actually create a new data object, but only the `layout' of a structure. For example, to create a 'point' data object, an additional VAR statement is required:

VAR point_a[POINT], point_b[POINT];

This statement creates two pointstructures called point_a and point_b. The members of such structures can be addressed using the subscript operator: point_a[PT_x] and point_a[PT_y].

Structures do not really have an own type. As the declaration and member access syntax already suggests, they are ordinary arrays and the member names are constants. In fact, the statement

STRUCT s = a, b, c;

is perfectly equal to

CONST s=3, a=0, b=1, c=2;

The STRUCT statement only defines symbolic names for accessing vector members with a fixed position and meaning. The structure name is another constant which holds the number of constants used to name the members (and therefore the size of the entire structure in machine words).

Previous:
2.4.3 Vectors
TOC | Index | Back Next:
2.5 Factors