From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: lloda Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] New function array-mutable? Date: Thu, 25 Nov 2021 20:10:49 +0100 Message-ID: References: <32F75DE0-14DA-4B7F-B6A9-81462A847A30@sarc.name> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_D8A6ED09-ADB4-42A0-8BED-25CF40DA693F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18341"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel To: Maxime Devos Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Nov 25 20:11:27 2021 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqK9X-0004YR-9h for guile-devel@m.gmane-mx.org; Thu, 25 Nov 2021 20:11:27 +0100 Original-Received: from localhost ([::1]:33520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqK9V-0001JE-FF for guile-devel@m.gmane-mx.org; Thu, 25 Nov 2021 14:11:25 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqK91-0001I4-TM for guile-devel@gnu.org; Thu, 25 Nov 2021 14:10:55 -0500 Original-Received: from mta-09-4.privateemail.com ([68.65.122.29]:43104) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqK8z-0004FK-MU for guile-devel@gnu.org; Thu, 25 Nov 2021 14:10:55 -0500 Original-Received: from mta-09.privateemail.com (localhost [127.0.0.1]) by mta-09.privateemail.com (Postfix) with ESMTP id B251F18000A6; Thu, 25 Nov 2021 14:10:51 -0500 (EST) Original-Received: from [192.168.1.105] (unknown [10.20.151.207]) by mta-09.privateemail.com (Postfix) with ESMTPA id F275018000A2; Thu, 25 Nov 2021 14:10:50 -0500 (EST) In-Reply-To: X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass client-ip=68.65.122.29; envelope-from=lloda@sarc.name; helo=MTA-09-4.privateemail.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20986 Archived-At: --Apple-Mail=_D8A6ED09-ADB4-42A0-8BED-25CF40DA693F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 25 Nov 2021, at 19:19, Maxime Devos wrote: >=20 > lloda schreef op do 25-11-2021 om 17:40 [+0100]: >> [...] >=20 > Suggestion: add a few tests to test-suite/tests/arrays.test: >=20 > (pass-if-equal "new" > #t > (array-mutable? (make-array #f '(1 2) '(3 4)))) >=20 > (pass-if-equal "empty (two-dimensional)" > #t > (array-mutable? (array-copy #1()))) >=20 > (pass-if-equal "empty (two-dimensional)" > #t > (array-mutable? (array-copy #2(() ())))) >=20 > (pass-if-equal "immutable copy" > #f > (array-mutable? (immutable-array-copy #2((h) (h))))) >=20 > This requires a currently non-existent procedure =E2=80=98make-immutable= - > array=E2=80=99, copying an array into a new immutable array. >=20 > 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 --Apple-Mail=_D8A6ED09-ADB4-42A0-8BED-25CF40DA693F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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 =E2=80=98make-immutable-
array=E2=80=99, 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

= --Apple-Mail=_D8A6ED09-ADB4-42A0-8BED-25CF40DA693F--