[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] New function array-mutable?

From: lloda
Subject: Re: [PATCH] New function array-mutable?
Date: Thu, 25 Nov 2021 20:10:49 +0100

On 25 Nov 2021, at 19:19, Maxime Devos <> wrote:

lloda schreef op do 25-11-2021 om 17:40 [+0100]:

Suggestion: add a few tests to test-suite/tests/arrays.test:

(pass-if-equal "new"
 (array-mutable? (make-array #f '(1 2) '(3 4))))

(pass-if-equal "empty (two-dimensional)"
 (array-mutable? (array-copy #1())))

(pass-if-equal "empty (two-dimensional)"
 (array-mutable? (array-copy #2(() ()))))

(pass-if-equal "immutable copy"
 (array-mutable? (immutable-array-copy #2((h) (h)))))

This requires a currently non-existent procedure ‘make-immutable-
array’, copying an array into a new immutable array.


I think literal arrays are always immutable, and one could base the test on that.

Is such a function useful in some other context? If one has an array which is already immutable, it can be referenced freely and copying it seems unnecessary. If one has a mutable array, is there any reason why one would want to make an immutable copy?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]