From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#8711: 24.0.50; binding _ to unused values with lexical-binding Date: Mon, 23 May 2011 22:16:22 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306181833 26304 80.91.229.12 (23 May 2011 20:17:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 20:17:13 +0000 (UTC) To: 8711@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 23 22:17: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 1QObYq-0006Pr-NO for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 22:17:09 +0200 Original-Received: from localhost ([::1]:36828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYp-0003ZF-RW for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 16:17:07 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYm-0003Z6-2X for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:17:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QObYk-0006QX-TU for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:17:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYk-0006QS-Qc for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QObYk-0002hP-8U; Mon, 23 May 2011 16:17:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Helmut Eller 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 20:17:02 +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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.130618181610360 (code B ref -1); Mon, 23 May 2011 20:17:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 May 2011 20:16:56 +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 1QObYd-0002h3-1r for submit@debbugs.gnu.org; Mon, 23 May 2011 16:16:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QObYb-0002gr-1G for submit@debbugs.gnu.org; Mon, 23 May 2011 16:16:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QObYS-0006OZ-0A for submit@debbugs.gnu.org; Mon, 23 May 2011 16:16:47 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:34438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYR-0006OV-V8 for submit@debbugs.gnu.org; Mon, 23 May 2011 16:16:43 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYR-0003Yl-1e for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:16:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QObYP-0006OB-Vl for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:16:43 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:54215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObYP-0006Nz-GO for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:16:41 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QObYK-00067q-Og for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 22:16:36 +0200 Original-Received: from 212.46.168.133 ([212.46.168.133]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 May 2011 22:16:36 +0200 Original-Received: from eller.helmut by 212.46.168.133 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 May 2011 22:16:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.46.168.133 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:NwQ1CWdzIKItV8IcHh7zwLoZ6uI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 23 May 2011 16:17:02 -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:46668 Archived-At: * Stefan Monnier [2011-05-23 19:29] writes: >> 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. Indeed. But I quickly run into another case where that doesn't help: (defun foo (x) (destructuring-bind (y &rest _) x y)) >> 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. The semantic of loop (in Common Lisp) allows both variants. So the "portable" idiom is "collect (let ((value value)) (lambda () value))". Helmut