From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: MON KEY Newsgroups: gmane.emacs.bugs Subject: bug#6878: bool-vectors of length 0 signal error when aref/aset the 0th element Date: Sat, 21 Aug 2010 13:02:47 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1282410563 28683 80.91.229.12 (21 Aug 2010 17:09:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 21 Aug 2010 17:09:23 +0000 (UTC) Cc: Juanma Barranquero , Chong Yidong , Andreas Schwab , 6878@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 21 19:09:21 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OmrZF-0007no-Fs for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Aug 2010 19:09:17 +0200 Original-Received: from localhost ([127.0.0.1]:33216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OmrZE-00080C-UQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Aug 2010 13:09:16 -0400 Original-Received: from [140.186.70.92] (port=57181 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OmrZ6-0007yw-Ro for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2010 13:09:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OmrZ5-0000H5-9x for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2010 13:09:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39161) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmrZ5-0000Gz-8d for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2010 13:09:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OmrSD-0000QG-Nr; Sat, 21 Aug 2010 13:02:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: MON KEY Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Aug 2010 17:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6878 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6878-submit@debbugs.gnu.org id=B6878.12824100981615 (code B ref 6878); Sat, 21 Aug 2010 17:02:01 +0000 Original-Received: (at 6878) by debbugs.gnu.org; 21 Aug 2010 17:01:38 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmrRp-0000Q0-OO for submit@debbugs.gnu.org; Sat, 21 Aug 2010 13:01:38 -0400 Original-Received: from mail-ww0-f46.google.com ([74.125.82.46]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmrRn-0000Pt-Hw for 6878@debbugs.gnu.org; Sat, 21 Aug 2010 13:01:36 -0400 Original-Received: by wwb22 with SMTP id 22so5909428wwb.15 for <6878@debbugs.gnu.org>; Sat, 21 Aug 2010 10:02:47 -0700 (PDT) Original-Received: by 10.216.185.211 with SMTP id u61mr709987wem.12.1282410167442; Sat, 21 Aug 2010 10:02:47 -0700 (PDT) Original-Received: by 10.216.65.140 with HTTP; Sat, 21 Aug 2010 10:02:47 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: g0dkeSEtOgbnS0IDHJxfQE5JK0M X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 21 Aug 2010 13:02:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39692 Archived-At: On Wed, Aug 18, 2010 at 3:36 AM, Stefan Monnier wrote: >> When aref/aset'ing the 0th element of a bool-vectors of length 0 i get >> an args-out-of-range error: > > To have a 0th element, an array needs to be of length >=3D 1. > So this behavior seems perfectly correct to me. > An array of length N has elements 0..N-1, so an array of length > 0 doesn't have any elements at all. =C2=A0This should be true of strings, > vectors, and bool-vectors. > Note, a similar such issue was addressed by David Moon during the ANSI Comm= on Lisp standardization process. :SEE ftp://ftp.parc.xerox.com/pub/cl/cleanup/old-mail/bit-array-functions.m= ail.Z ,---- | Date: Tue, 23 May 89 14:42 EDT | From: David A. Moon | Subject: Issue: BIT-ARRAY-FUNCTIONS (version 5) | | Proposal (BIT-ARRAY-FUNCTIONS:ADD): | | Allow the binary bit-array functions referenced above to accept | arguments of identical rank but unequal dimensions. Nonexistent | elements of bit-array-1 or bit-array-2 are assumed to be zero. If | the third argument is T or a bit-array, result elements outside the | bounds of the array must be zero or an error should be signalled. | If the third argument is NIL or omitted, each dimension of the | result array is equal to either the corresponding dimension of | bit-array-1 or the corresponding dimension of bit-array-2. The | larger of the two dimensions is used when necessary to hold all the | nonzero elements of the result, otherwise either the larger or the | smaller of the two dimensions is used. | `---- What is interestingly relevent to this bug report #6788 w/re bool-vectsrs was Barry Margolin's initial response to Moon's proposal above: Date: Mon, 19 Jun 89 13:31 EDT From: Barry Margolin Subject: Issue: BIT-ARRAY-FUNCTIONS (version 6) ,---- | | I'd like to suggest an additional change, which seems to be | consistent with the attitude about use of bit vectors expressed in | the proposal. The BIT and SBIT functions should return 0 if asked | to access outside the bit array. This would maintain the tautology | | (bit (bit-XXX v1 v2) n) =3D=3D (logXXX (bit v1 n) (bit v2 n)) | | If slowing down these functions (they'd be the only array accessors | REQUIRED to check the dimensions) is considered unacceptable, then a | new accessor should be added. | `---- Disregarding the fact that Emacs Lisp does not have anything equivalent to the Common Lisp bit array functions it remains noteworthy that a similar issue was considered during the Common Lisp ratification and that a somewhat similar incontinuity was detected with one aspect of a proposed solution being Margolin's suggestion that: "The BIT and SBIT functions should return 0 if asked to access outside the bit array." Indeed, while I was not aware of Margolin's proposal at the time I filed the current bug report his solution bears striking resemblance to the one I provided with my initial bug report, namely: ,---- | | Maybe something like this is needed: | | (defun safe-aref-bool-vector (bool-vector idx) | (if (and (bool-vector-p bool-vector) | (not (null (append bool-vector nil)))) | (aref bool-vector idx) | 0)) | | (defun safe-aset-bool-vector (bool-vector idx) | (if (and (bool-vector-p bool-vector) | (not (null (append bool-vector nil)))) | (aset bool-vector idx) | 0)) | `---- > > =C2=A0 =C2=A0 =C2=A0 =C2=A0Stefan -- /s_P\