Re: SRFI 231: Importing existing data
Bradley Lucier 24 Apr 2022 16:55 UTC
On 1/18/22 7:19 AM, Jens Axel Søgaard wrote:
> Following your lead I added make-specialized-arrary-from-data to the
> Racket implementation.
>
> https://github.com/soegaard/srfi-array/commit/6a514a3f8ef253ce31708bae8422288e96489e5f
> <https://github.com/soegaard/srfi-array/commit/6a514a3f8ef253ce31708bae8422288e96489e5f>
>
> For now I added a single test for the generic case.
>
> (let ()
> (define data (vector 10 11 12 13))
> (define A (make-specialized-array-from-data data))
> (test (eq? (array-body A) data) #t)
> (test (array->list A) '(10 11 12 13)))
Dear Jens Axel:
I just realized that make-specialized-array-from-data could be passed an
immutable object as its body's data while specifying the resulting array
to be mutable.
I suppose the Common Lisp way to deal with this would be to create a
mutable copy of the data as the body of the resulting array.
But I'm inclined to say "It is an error", although I don't see how to
check this in a portable way. (And it would even be difficult to check
in the test program, because literals in code are mutable when processed
by Gambit's interpreter and immutable when compiled.)
Ideas?
Brad