From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#8711: 24.0.50; binding _ to unused values with lexical-binding Date: Mon, 23 May 2011 16:29:01 -0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306179013 6446 80.91.229.12 (23 May 2011 19:30:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 19:30:13 +0000 (UTC) Cc: 8711@debbugs.gnu.org To: Helmut Eller Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 23 21:30:09 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOapM-0007Af-7C for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 21:30:08 +0200 Original-Received: from localhost ([::1]:33439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOapL-0005Fo-P8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 15:30:07 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOapJ-0005Er-Lc for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 15:30:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOapI-00070j-L5 for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 15:30:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOapI-00070Q-Hs for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 15:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOapH-0001cy-Vx; Mon, 23 May 2011 15:30:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 May 2011 19:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8711 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8711-submit@debbugs.gnu.org id=B8711.13061789536172 (code B ref 8711); Mon, 23 May 2011 19:30:03 +0000 Original-Received: (at 8711) by debbugs.gnu.org; 23 May 2011 19:29:13 +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 1QOaoR-0001bV-Ve for submit@debbugs.gnu.org; Mon, 23 May 2011 15:29:12 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOaoQ-0001bK-Bc for 8711@debbugs.gnu.org; Mon, 23 May 2011 15:29:11 -0400 Original-Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:59283 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QOaoK-0000Ht-K4; Mon, 23 May 2011 15:29:04 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 253E266131; Mon, 23 May 2011 16:29:01 -0300 (ART) In-Reply-To: (Helmut Eller's message of "Mon, 23 May 2011 20:23:52 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 23 May 2011 15:30:03 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46665 Archived-At: > My problem is basically that I have a macro "destructure-case" that > expands to destructuring-bind, e.g.: > (destructure-case location > ((:error _) nil)) ; do nothing > expands to > (ecase (car location) > (:error (destructuring-bind (_) (cdr location) > (ignore _) > nil))) > The macro inserts the (ignore _) to suppress the "value returned from > (car --cl-rest--) is unused" warning. It can insert (ignore nil) instead which should have the same effect but without triggering the other warning with lexical-binding. > I think that rewriting (let ((_ foo))) to (progn foo nil) is not quite > right because that loses the information that the value that flows to > the variable _ is intentionally ignored, but I guess that is somewhat > hard to fix this. (Maybe byte-optimize-letX could call > byte-optimize-form-code-walker directly but instead of specifying that > the form is evaluated "for-effect" somehow say that the value is > "ignorable".) I'm not completely satisfied with the "value returned from is unused" indeed, but it's not clear exactly how to fix it (short of always silencing it, which I'd rather not since it occasionally catches errors). > It's perhaps easier to teach destructuring-bind the _ convention so that > it can produce more direct code. Could be. destructuring-bind generates some other minorly-problematic code for the lexbind case. > There is also a somewhat related problem with loop: > ;; -*- lexical-binding: t -*- > (defun foo (alist) (loop for (_key . value) in alist collect value)) > produces a "variable `_key' not left unused" warning. I think the same problem happens with dotimes/dolist using the old definition: the loop vars `key' and `value' are let-bound outside the loop and then setq'd at each loop iteration (it's this setq that causes them to be "not left unused"). This was OK for the dynamic scoping case because let-binding is significantly more costly than setq, but it is not right for the lexical scoping case where the cost of let is not higher than `setq' and where the semantic is actually then wrong: e.g. if you "collect (lambda () value)" the current code ends up returning a list of functions that all return the last `value', rather than a list of functions that each return one of the `values' in the alist. Stefan