Possibilities / Limitations of Z language

 

Structures
Compound types
Array
Reading / Writing
High level operations
Global assignment
Files
 

 

 

Structures

A structure can be
- simple ( scalar, scalar, ... )
-complex ( scalar or one-dimensional array of scalars, scalar or one-dimensional array of scalars, ...)
A structure can be static or dynamic.
A dynamic structure is a simple structure. It cannot have inside dynamic arrays.

We can have a structure formed of a single element.
Example: LET S : (INTEGER) ;

Arrays


An array can be static or dynamic.
The dimension of an array cannot exceed 5.

We cannot have a dynamic array of dynamic structures.
We can't have an array of complex structures.

For an array defined as follows

LET T3 : ARRAY ( 3 ) OF ARRAY ( 2 ) ;
We cannot do:
INIT_VECT ( T3 , [ [ 23 , 7 ] , [ 2 , 3 ] , [ 78 , 34 ] ] ) ;
do this instead:
INIT_VECT ( T3 , [ V1 , V2, V3] ) ;

High level operations

For all high-level operations, the element can be a scalar or a simple structure.

(Init_vect, creATE_list, ...)
On the other hand, for init struct, we can have a complex structure

Example : init_struct( S,[ 'zz', [12, 23, 32], 7);
We can't do:

creATE_list(L, [ [12, 23, 22], [22, 66, 88],  ...]);
Init_vect (V, [ [12, 23, 22], [22, 66, 88] ... ]);

Expressions can be used in high-level operations.

Files

The element of a file can be:
- a simple structure
- a complex structure
- an array of scalars
- a scalar

The header is a simple structure.
The HEADER  part is optional.
The BUFFER  part is optional.

Syntax: the HEADER part precedes the BUFFER part.

We can't write:
- LET f1,f2 : FILE OF ...
It is necessary to make individual statements.

Compound types

A compound type is defined as follows:
Type OF Type OF.... OF X
with
Type in { List, BiList, Bst, Mst, Array, Queue, Stack}
X is either a scalar or a simple structure.
Reading / Writing

We can read/write a simple or complex structure (static or dynamic)
We can read/write an array of scalars with one or more dimensions (static or dynamic)
Global Assignment

We can make global assignments of arrays and static structures.
This is about creating a copy and not a simple pointer assignment.

For arrays, we will limit ourselves to arrays of scalars or simple structures.