Comments about interval specifications Bradley Lucier 08 Nov 2026 18:50 UTC

The document says:
==================================
Here is an EBNF grammar for array literals (ignoring case and whitespace):

array-literal ::= "#a" tag bounds datum
tag ::= letter (letter | digit)*
bounds = "(" bound* ")"
bound := (number | "(" number number ")")

Note that the numbers must represent exact integers.
==================================
with the examples
==================================
Some empty arrays:

#a(1 0) ()
#a((2 1) (2 3)) (() ())
==================================

The last example does not result in an empty array with Chibi's
implementation of SRFI 231 and the sample implementation of SRFI 268.
Using string->array from the test file, we see

 > (string->array "#a((2 1) (2 3)) (() ())")
ERROR: assertion failed
     (and (translation? lo) (translation? hi) (= (vector-length lo)
(vector-length hi)) (vector-every <= lo hi))
     (lo #(2 2))
     (hi #(1 3))
     (<= #<opcode "<=" 2+>)

This error is raised in Chibi's implementation of SRFI 231, which
requires that each lower bound must be <= the corresponding upper bound.

If SRFI 268 is to follow SRFI 231's limitations on upper and lower
bounds, I suggest the document say something like
==================================
Here is an EBNF grammar for array literals (ignoring case and whitespace):

array-literal ::= "#a" tag bounds datum
tag ::= letter (letter | digit)*
bounds = "(" bound* ")"
bound := (number | "(" low high ")")

Note that number, low, and high must represent exact integers, number
must be nonnegative, and low must be no greater than high.
==================================

This also raises an error in SRFI 231:

 > (string->array "#a(-3)()")
ERROR: assertion failed
     (and (translation? lo) (translation? hi) (= (vector-length lo)
(vector-length hi)) (vector-every <= lo hi))
     (lo #(0))
     (hi #(-3))
     (<= #<opcode "<=" 2+>)

Do you want to catch these issues in SRFI 268's sample implementation,
or do you want to hand off to the underlying array implementation?

Also, isn't the tag optional?  I get

 > (array->list* (string->array "#a(2)(1 2)"))
(1 2)

i.e., this works.

Brad