guile-devel
[Top][All Lists]
Advanced

[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 <maximedevos@telenet.be> 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"
 #t
 (array-mutable? (make-array #f '(1 2) '(3 4))))

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

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

(pass-if-equal "immutable copy"
 #f
 (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.

Greetings,
Maxime

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?

regards

Daniel


reply via email to

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