syntax for inferred upper bound
Peter McGoron 15 Apr 2026 11:36 UTC
I still think this is a good idea to allow the upper bound to be
inferred from the length of the dimensions.
Here is an alternative proposal that explicitly labels the upper bound
as inferred. The EBNF grammar is changed to become
array-literal ::= "#a" tag bounds datum
tag ::= letter (letter | digit)*
bounds = "(" bound* ")"
bound := (number | "(" number number ")" | "(" number placeholder")")
placeholder := the symbol "?"
When ? is an upper bound, the upper bound is inferred from the length of
the array. If the array is empty in that dimension, then the inferred
upper bound is the same as the lower bound.
The syntax is matched symbolically: "?" is not an identifier.
Examples:
#a u32 ((0 ?) (0 ?))
((10 11)
(20 21))
is equivalent to
#a u32 ((0 2) (0 2))
((10 11)
(20 21))
__________________
#a ((2 ?) (3 ?))
((a b)
(c d))
is equivalent to:
#a ((2 4) (3 5))
((a b)
(c d))
__________________
#a s32 ((1 ?) (1 ?))
((-1 0 0 0)
(0 1 0 0)
(0 0 1 0)
(0 0 0 1))
is equivalent to
#a s32 ((1 5) (1 5))
((-1 0 0 0)
(0 1 0 0)
(0 0 1 0)
(0 0 0 1))
_____________________
# a ((2 ?) (2 ?))
(() ())
is equivalent to
#a ((2 2) (2 2))
(() ())
-- Peter McGoron