array-rebase, similar to Chibi's array-to-origin Bradley Lucier 18 Jan 2025 18:25 UTC

Alex Shinn has added array-to-origin to his SRFI 231 implementation,
which translates an array to have all zero lower bounds.

This is useful.

It is also useful to be able to translate a bunch of arrays that all
have the same widths to have the same lower and upper bounds.

Or, more generally, to set the lower bounds of an array to given values.

So I think it would be useful to have

(array-rebase array [lower-bounds])

which will translate an array to have the given lower bounds, or
translate it to have lower bounds zero if the optional argument
lower-bounds is omitted.

So I'm going to add this to the list of things to change if a new draft
is needed.

Brad

Things to change in a future library:

1.  (srfi 231) is "safe", with an "unsafe" library (srfi 231 unsafe);
mixing safe and unsafe arrays and operations could be accomplished by
renaming routines.

2.  Get rid of array-freeze!

3.  Do not fix the order of evaluation of array elements in arguments to
the "bang" (!) procedures.

4.  Add (array-rebase array [lower-bounds]) to translate an array to
given lower bounds.