docs: document array[NamedSubrange] index type

grammar.ebnf: the ARRAY [IDENT] OF T form is an ordinal-indexed array;
clarify it admits both an enumeration type and a named integer subrange
as the index, with a note on how each folds (enum -> array[0..N-1],
subrange -> array[lo..hi]).

language-rationale.adoc: add the array[TSubrange] of T row to the
supported array-index table, noting the subrange supplies the index
range while its values remain ordinary unchecked integers.
This commit is contained in:
Graeme Geldenhuys 2026-06-30 21:23:35 +01:00
parent 1035dcc1c9
commit ac6e0b0d88
2 changed files with 13 additions and 1 deletions

View file

@ -738,9 +738,18 @@ QualIdent
ArrayType
= ARRAY LBRACKET ArrayBound DOTDOT ArrayBound
{ COMMA ArrayBound DOTDOT ArrayBound } RBRACKET OF TypeName
| ARRAY LBRACKET IDENT RBRACKET OF TypeName (* ordinal/enum-indexed *)
| ARRAY LBRACKET IDENT RBRACKET OF TypeName (* ordinal-indexed *)
;
(* The IDENT form names an ORDINAL index type. Two ordinal kinds are admitted:
* - an enumeration type (array[TColor] of T folds to array[0..N-1] of T,
* where N is the member count), and
* - a NAMED integer subrange (type TIdx = lo..hi; array[TIdx] of T folds to
* array[lo..hi] of T). The subrange supplies only the index range; the
* values it yields remain ordinary unchecked integers of the subrange's
* underlying storage type.
* See language-rationale.adoc "Array index types". *)
ArrayBound
= ConstArithExpr
;

View file

@ -1154,6 +1154,9 @@ Blaise supports fixed-size, stack-allocated arrays declared as
| `array[TEnum] of T` — enum-type index
| Supported
| `array[TSubrange] of T` — named integer-subrange index
| Supported. The subrange (`type TIdx = lo..hi;`) supplies the index range, so `array[TIdx] of T` folds to `array[lo..hi] of T`; the subrange's values remain ordinary unchecked integers of its underlying storage type.
| `array[L..H, M..N] of T` — multi-dimensional
| Supported