Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
Type Sample TupleDEFINITION MODULE SampleTuple; (* Sample definition of a vector derived tuple type, all components are the same *) FROM FileIO IMPORT File; (* required for IO *) (* component type *) TYPE ComponentType IS REAL; (* arbitrary numeric type *) (* SampleTuple type *) TYPE SampleTuple = OPAQUE RECORD ("V-Type") capacity : CARDINAL; values : ARRAY capacity OF ComponentType; END; (* cardinality *) PROCEDURE [HIGH] highestComponentIndex ( t : SampleTuple ) : CARDINAL; (* constructor *) PROCEDURE Tuple ( items : CARDINAL; VARIADIC v[items] OF c : ComponentType ) : SampleTuple; (* constructs a tuple from a value list *) (* accessor *) PROCEDURE [.] component ( n : CARDINAL; t : SampleTuple ) : REAL; (* Returns the value of the n-th component of tuple t *) (* mutator *) PROCEDURE [!] setComponent ( n : CARDINAL; VAR t : SampleTuple; c : ComponentType ); (* Overwrites the value of the n-th component of tuple t with c *) (* monadic arithmetic operations *) PROCEDURE [ABS] abs ( t : SampleTuple ) : SampleVector; (* relational operations *) PROCEDURE [=] isEqual ( t1, t2 : SampleTuple ) : BOOLEAN; (* IO operations, bound to READ, WRITE and WRITEF *) PROCEDURE Read( infile : File; VAR t : SampleTuple ); PROCEDURE Write( outfile : File; t : SampleTuple ); PROCEDURE WriteF( outfile : File; fmtStr : ARRAY OF CHAR; items : CARDINAL; VARIADIC v[items] OF t : SampleTuple ); END SampleTuple. |