Re: no feedback on srfi-164 Enhanced multi-dimensional Arrays
Per Bothner 15 Dec 2018 01:03 UTC
On 12/14/18 11:01 AM, Bradley Lucier wrote:
> On 12/14/18 1:55 PM, John Cowan wrote:
>>
>>
>> On Fri, Dec 14, 2018 at 1:02 PM Per Bothner <xxxxxx@bothner.com <mailto:xxxxxx@bothner.com>> wrote:
>>
>> Cowan has mentioned a range API:
>> However, it is not a specification - arguments aren't even specified.
>> (It is also way too big an API in my opinion.)
>>
>>
>> It's still evolving.
>
>
> By a "range API", do you mean something like what I call "intervals" in SRFI 122?
Not quite, though they're related.
What SRFI 122 calls "interval" has similar function as "shape" in SRFI 25 and SRFI 164,
but "shape" is not a distinct type in the latter. SRFI 164 also has the concept of a
"shape specifier" which is a value that can be used where a shape is required.
For example instead of
(make-interval '#(0 0) (vector row columns))
a valid shape specifier is simply:
(vector row columns)
or more generally:
(vector (list 0 rows) (list 0 columns))
It is probably cleaner to have a distinct "interval" type (though preferably
using a different name), but I'm not sure it is worth it. Having 20 different
new procedures seems overkill to me.
A "range" is a sequence - it can be treated as a space-optimized immutable vector.
(In contrast an "interval" is a set - there is no inherent order.) A "range" has an optional
"step", which is the increment between successive members of the range. The step is most
often 1, but can be some other value - a negative values reverses the order.
Ranges are very convenient for taking slices (sub-arrays) and some other common
index transformations (such as reverse).
On the other hand, a range has a single dimension, while an interval
may be multi-dimensional. A vector of ranges that all have a step of 1 is
equivalent to an interval, and is one kind of allowed shape specifier.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/