Re: relationship to SRFI-25 Bradley Lucier 31 Jul 2015 21:00 UTC

On 07/30/2015 01:30 AM, Per Bothner wrote:
> What is not discussed is how SRFI-122 differs from SRFI-25, and why?

SRFI-25 states:

=====================================================================
(make-array shape)
(make-array shape obj)
Returns a newly allocated array whose shape is given by shape. If obj is
provided, then each element is initialized to it. Otherwise the initial
contents of each element is unspecified. The array does not retain a
dependence to shape.
=====================================================================
and
=====================================================================
(array shape obj ...)
Returns a new array whose shape is given by shape and the initial
contents of the elements are obj ... in row major order. The array does
not retain a dependence to shape.
=====================================================================

In this SRFI, (array domain getter) allocates nothing except a few words
of memory for a structure that contains pointers to domain and getter.
There is no automatic allocation of arrays (or what this SRFI calls
array-body's), everything can be left as a function.

SRFI-25 states

=====================================================================
(array-set! array k ... obj)
(array-set! array index obj)
Stores obj in the element of array at index k .... Returns an
unspecified value. The sequence k ... must be a valid index to array. In
the second form, index must be either a vector or a 0-based
1-dimensional array containing k ....

    (let ((a (make-array
                (shape 4 5 4 5 4 5))))
       (array-set! a 4 4 4 'huuhkaja)
       (array-ref a 4 4 4))

Returns huuhkaja.
=====================================================================

In this SRFI, arrays don't have to be mutable.

>
> How is a SRFI-122 interval different from a SRFI-25 shape?

It isn't.

>
> Why can't SRFI-122 be a compatible superset of SRFI-25?

Hopefully I've explained above.

>
> Why would anyone want to write:
>   ((array-getter a) i j)
> instead of:
>   (array-ref a i j)

No one would.  This SRFI encourages a style of programming that's
different from the "store and move around one object at a time" style.

Brad