Skip to content

Eberon array initializers

vladfolts edited this page May 27, 2016 · 1 revision

Array initializers create array with specified elements as a shortcut instead of declaring array variable and initialize each element separately.

Syntax

"[" expression {, expression} "]"

Example

MODULE test;
CONST a = [1, 2, 3];

PROCEDURE passArray(a: ARRAY OF INTEGER);
END;

BEGIN
	passArray(a);
	passArray([123, 456]);
END test.

Semantics

  • all expressions used in initializers list must have the same type
  • if string literal is used as expression then element's type is STRING
  • array initializers can be used to define a constant in CONST section
  • array initializers can be used wherever constant expression of corresponded array's type can be used

Clone this wiki locally