usefulness in code Peter McGoron (31 Mar 2026 12:07 UTC)
Re: usefulness in code Peter McGoron (31 Mar 2026 14:54 UTC)
Re: usefulness in code John Cowan (31 Mar 2026 16:03 UTC)
Re: usefulness in code Alex Shinn (31 Mar 2026 21:56 UTC)
Re: usefulness in code Peter McGoron (02 Apr 2026 10:46 UTC)
Re: usefulness in code John Cowan (02 Apr 2026 22:38 UTC)

usefulness in code Peter McGoron 31 Mar 2026 12:02 UTC

How often would array literals be used in code? Unlike Matlab, Python,
or other language, an array literal is a constant in the same way a
string or a complex number is. You can't quasiquote numerical
constants[1] so one can only write constant numerical arrays. Unlike
numerical constants or strings, people commonly use compound operations
in arrays, so I don't know how much use array datum syntax would get.

I like array literals for data serialization, however. In that case,
there is not much use to have all of the special cases and shortcuts
that the current grammar has, because it's designed to be machine
readable. It could be simplified so that one does not have to omit the
number of dimensions.

I would like to see a EBNF grammar for the syntax. Whatever design we
end up going with, I'm willing to write that.

I would also like to see `read-array` and `write-array` procedures,
similar to the procedures in SRFI 267 (raw string literals) and in SRFI
207 (string notated bytevectors). I could also write those.

[1]: See comment
<https://codeberg.org/scheme/r7rs/issues/310#issuecomment-12290376>.
TR7, the only Scheme I know that allows quasiquotation of bytevectors,
expands

          '`#u8(1 2 ,@my-list)

      as

          '(apply bytevector `(1 2 ,@my-list))

      such that, when '`#u8(1 2 ,@my-list) is evaluated, it returns the
appropriate bytevector.

      This discussion doesn't apply to array that can contain any
element, because they can be quasiquoted in a similar way to lists and
vectors.

-- Peter McGoron