Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 767 Bytes

Definite-Array-Expression.md

File metadata and controls

31 lines (22 loc) · 767 Bytes
title parent
Definite Array Expression
Constructors.md

Syntax

definite_array_expr ::= '[' (expr ',')* ']'
                      | '[' expr ',' '..' literal ']'

The last comma in the first case is optinal.

Typing

  1. The expression [e_1, ..., e_n] has type [T * n] if all e_i are of type T.
  2. The expression [e, .. n] has type [T * n] if all e_i are of type T. n must be a constant.

Semantics

  1. All elements are evaluated from left to right and packed into a [[Definite Array]].
  2. The expression is evaluated and n-times duplicated in order to be packed into a [[Definite Array]].

Examples

let a = [1, 2, 3];
let b = [[1, 2], [3, 4]];
let c = [23, .. 4];