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: Fri, 20 Aug 2010 14:44:12 -0400 Message-ID: References: <87r5hutw2q.fsf@stupidchicken.com> <87fwyauqwy.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1282331354 8987 80.91.229.12 (20 Aug 2010 19:09:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 20 Aug 2010 19:09:14 +0000 (UTC) Cc: lekktu@gmail.com, cyd@stupidchicken.com, schwab@linux-m68k.org, 6878@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 20 21:09:12 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 1OmWxk-0002cD-8T for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Aug 2010 21:09:12 +0200 Original-Received: from localhost ([127.0.0.1]:55098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OmWxi-0005sB-Re for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Aug 2010 15:09:10 -0400 Original-Received: from [140.186.70.92] (port=53956 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OmWxd-0005s5-Ct for bug-gnu-emacs@gnu.org; Fri, 20 Aug 2010 15:09:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OmWxb-0003Tn-Vn for bug-gnu-emacs@gnu.org; Fri, 20 Aug 2010 15:09:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38916) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmWxb-0003Tj-UR for bug-gnu-emacs@gnu.org; Fri, 20 Aug 2010 15:09:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OmWZN-0004JC-SN; Fri, 20 Aug 2010 14:44: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: Fri, 20 Aug 2010 18:44: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.128232978516550 (code B ref 6878); Fri, 20 Aug 2010 18:44:01 +0000 Original-Received: (at 6878) by debbugs.gnu.org; 20 Aug 2010 18:43:05 +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 1OmWYS-0004It-WE for submit@debbugs.gnu.org; Fri, 20 Aug 2010 14:43:05 -0400 Original-Received: from mail-ew0-f44.google.com ([209.85.215.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmWYR-0004IW-8X for 6878@debbugs.gnu.org; Fri, 20 Aug 2010 14:43:03 -0400 Original-Received: by ewy22 with SMTP id 22so2255001ewy.3 for <6878@debbugs.gnu.org>; Fri, 20 Aug 2010 11:44:13 -0700 (PDT) Original-Received: by 10.216.145.99 with SMTP id o77mr1541445wej.113.1282329852816; Fri, 20 Aug 2010 11:44:12 -0700 (PDT) Original-Received: by 10.216.65.140 with HTTP; Fri, 20 Aug 2010 11:44:12 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: 0mqUwEvYiOMLxcbO63ED4X4Zzfg X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 20 Aug 2010 14:44: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:39669 Archived-At: On Fri, Aug 20, 2010 at 9:02 AM, Stefan Monnier wrote: >> As you wish. Though, I don't think changing the wording solves the >> real problem If there are no good reasons to create a boole-vectro of >> length 0 why allow it? > > That's the wrong question. The question is: why not allow them? How about Juanma's example earlier wich is a mis-application of substring on vectors satisfying the predicate `bool-vector-p' e.g. his: > (defun split-vec (v p) > (list (substring v 0 p) > (substring v p (length v)))) > >> Emacs lisp doesn't and I can think of no good reasons to create 0 >> length bool-vectors. >> Can any one else? > > The same reasons to create zero-length strings. > I'm not convinced. Anyhow, my query included the caveat "good reasons" :) (substring (make-bool-vector 0 t) 0) ;=> Debugger entered--Lisp error: (wrong-type-argument arrayp #&0"") And, it doesn't really work for vectors either: (substring (make-vector 0 1) 0) ;=> [] Likewise, where is the sense in these: (apply 'string (append (make-bool-vector 0 t) nil)) ;=> "" (concat (make-bool-vector 0 t)) ;=> "" When this: (concat) ;=> "" and this: (apply 'string nil) ;=> "" would suffice. Note, I _do_ recognize that there is some utility for things like this w/ _vanilla_ vectors: (defmacro v->empty (&optional char-val-maybe) (let ((vvoid (make-symbol "vvoid"))) `(let ((,vvoid (if (characterp ,char-val-maybe) 1 0))) (make-vector ,vvoid ,char-val-maybe)))) (v->empty 'not-a-char) ;=> [] (v->empty 32) ;=> [32] (v->empty) ;=> [] (mapconcat #'identity (mapcar #'(lambda (ve) (concat (v->empty ve))) '(119 'not-a-char 32 nil 111 'nor-inil 32 "nope" 119 'nada 33)) "") But I can't see how the `make-vector' idiom would translate for `make-bool-vector'. > Stefan > -- /s_P\