Ideas for future array SRFIs: nominal data
John Cowan 12 Apr 2026 04:16 UTC
This is an idea for a wrapper around SRFI 231 arrays that allows the
dimensions to be named by symbols, and for each dimension, the
individual rows/columns/whatever to be named by symbols as well I got
this idea while looking for examples of 4D arrays, and found one in
which the elements represent an inventory of pants. The dimensions
are size, length, color, and fit (snug, straight, relaxed).
Now it's annoying to have to remember these, and just as annoying to
remember which rows/columns mean what. So in a nominal array we have
these names available as symbols, along with the underlying array, and
can use them in nominal-ref and nominal-set! operations. We construct
such an array like this:
(make-nominal s32-storage-class
'((size small medium large extra-large)
(length (range 30 42))
(color red green blue black)
(style fitted straight relaxed)))
And we get the number of pants in stock like this:
(nominal-ref inventory '((size . small) (length . 30) (color . blue)
(style . relaxed)))
This returns the same as::
(array-ref (nominal-underlying-array inventory) 0 30 2 2))
Because the index argument is an alist, its elements can appear in any order.
This needs a lot of fleshing out.