From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: _writable_elements & empty vectors Date: Thu, 14 Sep 2017 17:35:58 -0400 Message-ID: <87shfpyncx.fsf@netris.org> References: <4F48E2ED-D196-48F1-A012-3364A9104555@bluewin.ch> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1505424994 25597 195.159.176.226 (14 Sep 2017 21:36:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 14 Sep 2017 21:36:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-devel To: Daniel Llorens Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Sep 14 23:36:28 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsbo9-0006Sj-Am for guile-devel@m.gmane.org; Thu, 14 Sep 2017 23:36:25 +0200 Original-Received: from localhost ([::1]:50126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsboG-0005H3-PJ for guile-devel@m.gmane.org; Thu, 14 Sep 2017 17:36:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsbo6-0005Gg-Vz for guile-devel@gnu.org; Thu, 14 Sep 2017 17:36:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsbo3-00045u-2Y for guile-devel@gnu.org; Thu, 14 Sep 2017 17:36:23 -0400 Original-Received: from world.peace.net ([50.252.239.5]:37373) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsbo2-00045q-U3 for guile-devel@gnu.org; Thu, 14 Sep 2017 17:36:18 -0400 Original-Received: from pool-72-93-28-145.bstnma.east.verizon.net ([72.93.28.145] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dsbo1-0003H7-RR; Thu, 14 Sep 2017 17:36:17 -0400 In-Reply-To: <4F48E2ED-D196-48F1-A012-3364A9104555@bluewin.ch> (Daniel Llorens's message of "Mon, 11 Sep 2017 13:57:18 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 50.252.239.5 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19294 Archived-At: Daniel Llorens writes: > There is a whole set of functions scm_TYPE_writable_elements in > Guile. In 2.2 these functions must be called with mutable containers. > > The problem is that empty vectors or arrays are immutable, so one is > forced to guard every call to scm_TYPE_writable_elements with a > superfluous size check. > > E.g. > > (vector 1 2) -> new mutable vector > (vector 1) -> new mutable vector > (vector) -> const non-mutable vector > > This causes (sort! (vector) <) to fail in Guile 2.2. > > I think scm_TYPE_writable_elements should accept empty vectors whether > they're technically mutable or not, and return NULL. I agree. Even from a strictly logical standpoint, if we define "scm_TYPE_writable_elements" to mean "forall elements X in the object, X is mutable", then that statement is certainly true if there are no elements in the object. > Let me know if you disagree, otherwise I'll submit a patch. Sounds good, thanks! Mark