Proposed additional commentary for array-assign! Bradley Lucier 17 Nov 2026 16:15 UTC

I propose adding this sentence to the description of array-assign! in
the SRFI 231 document:

array-assign! neither specifies nor guarantees the order in which the
elements of source are evaluated nor the order in which those elements
are assigned to the associated multi-indices in destination.

together with the following examples.

I think that if the author of the SRFI was so confused about what is
happening that it should be laid out in the SRFI document.

Any comments?

Brad

Example of interleaving evaluating elements of source and assigning them
to destination:

(let* ((zeros-and-ones (map (lambda (n) (modulo n 2)) (iota 10)))
        (A (list*->array 1 zeros-and-ones u1-storage-class))
        (A-front (array-extract A (make-interval '#(9))))
        (A-front-translated (array-translate A-front '#(1)))
        (A-back (array-extract A (make-interval '#(1) '#(10))))
        (Aft_ (array-getter A-front-translated))
        (Ab! (array-setter A-back)))
   (display "A before assignment")
   (array-display A)
   (interval-for-each (lambda (i)
                        (Ab! (Aft_ i) i))
                      (array-domain A-back))
   (display "A after assignment")
   (array-display A))

#| Displays
A before assignment
0       1       0       1       0       1       0       1       0       1
A after assignment
0       0       0       0       0       0       0       0       0       0
|#

Example of evaluating all elements of source (in order) before assigning
them to destination:

(let* ((zeros-and-ones (map (lambda (n) (modulo n 2)) (iota 10)))
        (A (list*->array 1 zeros-and-ones u1-storage-class))
        (A-front (array-extract A (make-interval '#(9))))
        (A-front-translated (array-translate A-front '#(1)))
        (A-back (array-extract A (make-interval '#(1) '#(10)))))
   (display "A before assignment")
   (array-display A)
   (array-assign! A-back (array-copy A-front-translated))
   (display "A after assignment")
   (array-display A))

#| Displays
A before assignment
0       1       0       1       0       1       0       1       0       1
A after assignment
0       0       1       0       1       0       1       0       1       0
|#