diff --git a/docs/grammar.ebnf b/docs/grammar.ebnf index de02951..aa033f6 100644 --- a/docs/grammar.ebnf +++ b/docs/grammar.ebnf @@ -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 ; diff --git a/docs/language-rationale.adoc b/docs/language-rationale.adoc index 2e5dcf2..f8be8db 100644 --- a/docs/language-rationale.adoc +++ b/docs/language-rationale.adoc @@ -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