chickadee » generalized-arrays » make-array-from-storage

make-array-from-storage storage-class dimension storage-objectprocedure

Constructs an array of the provided storage-class and dimension with a provided storage-object. Unlike make-array, this does not allocate any storage object on its own. Additionally, it is an error if:

  • The storage-object is not a storage object of the provided storage-class
  • The length of the interval constructed by (make-default-interval dimension) is not exactly equal to the length of the storage-object.

This procedure is helpful if you are working with array data via SRFI-4 and / or SRFI-160 storage kinds but are constructing or managing the storage across the FFI boundary.

 
(import generalized-arrays
        test)

(define vec #f64(1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0))

(define arr
  (make-array-from-storage
    f64vector-storage-class #(3 3) vec))

(test "Storage object in array is equal to original f64vector"
      vec
      (array-storage-object arr))