An array is a fixed-length sequence of object references. Each array is an object, which value contains that references.
The array object inherits one of the two base objects:
||Immutable array. Such array can not be altered after initialization.|
||Mutable array. Array elements can be modified by the assignment statement.|
Note that array length can not be altered despite the array mutability.
Both of these objects inherited from
Indexed prototype, which declares an
interface for all objects containing indexed elements.
An array can be constructed and initialized with a special expression with the following syntax:
'[' [<item> [',' <item>] ...] ']'
<item> is an expression resolving to the corresponding array element’s
initial value; the number of items defines an array length.
The constructed array will inherit a
The type of elements will be determined automatically.
Every array is an object and can be constructed by the object constructor expression. The type of array elements can be specified as a type parameters:
Foo :=> void (Int :=< integer `link) Bar :=> foo (Str :=< string `link) Foo row := [foo (Int = 1), foo (Int = 2)] ~~ Elements type is `foo`. Bar row := bar` foo row (= [bar (Int = 1, Str = "One")]) ~~ Inherit the `foo row` and upgrade elements type to `bar`.
Array objects declare phrases, which can be used to
Integer` row [[1, 2, 3]] ~~ Row of integers String` array [["first", "second", "last"]] ~~ Array of strings: Array of strings := string` array = ["first", "second", "last"] ~~ Field initializer syntax
Array Element Access
An array element can be accessed with the following phrase:
<array> '[' <index> ']'
<array>is an expression resolving to target array;
<index>is an expression resolving to integer value, designating the requested element’s index (zero-based).
~~ The row of three integers. My array := [1, 2, 3] My array  ~~ Returns `2`. My array  ~~ False value, as element index is invalid. ~~ The array of two strings. Var-array := string` array [["one", "sec" + "ond"]] Var-array  ~~ `"second"` initially, until modified. Var-array  <- "two" ~~ Assign `"two"` to second element. Var-array  ~~ Now it's `"two"`.
Array Value Definition
Array has different value types,
but they can be converted from one to another:
Var-array := integer` array ( ~~ Declare the (mutable) array of integers. = [1, 2, 3] ~~ Initialize it with (immutable) row. )