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 20:23:52 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306175115 11601 80.91.229.12 (23 May 2011 18:25:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 18:25:15 +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 20:25: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 1QOZoS-0003Is-Sk for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 20:25:09 +0200 Original-Received: from localhost ([::1]:53836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZoS-0005zN-Dp for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 14:25:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:33072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZoN-0005xf-Or for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:25:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOZoM-0002fN-Nl for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:25:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZoM-0002fJ-L4 for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOZoM-000078-1M; Mon, 23 May 2011 14:25: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 18:25:01 +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.1306175062385 (code B ref -1); Mon, 23 May 2011 18:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 May 2011 18:24:22 +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 1QOZnh-00006A-Ap for submit@debbugs.gnu.org; Mon, 23 May 2011 14:24:21 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOZnb-00005u-W5 for submit@debbugs.gnu.org; Mon, 23 May 2011 14:24:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOZnV-0002Zx-PS for submit@debbugs.gnu.org; Mon, 23 May 2011 14:24:10 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:58333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZnV-0002Zt-Mt for submit@debbugs.gnu.org; Mon, 23 May 2011 14:24:09 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:32870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZnU-0005nq-EL for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:24:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOZnT-0002YB-Ai for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:24:08 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:44717) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZnT-0002Xp-0v for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 14:24:07 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QOZnR-0002dc-Qc for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 20:24:05 +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 20:24:05 +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 20:24:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 53 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:x7wYDlHDP5iMsULobL4WrgGa+5Y= 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 14:25: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:46664 Archived-At: * Stefan Monnier [2011-05-23 14:24] writes: > The two warnings come from different analyzes: > - The warning for `bar' comes from cconv.el which is intended to check > whether the variable is syntactically used, rather than semantically. > - The warning for `foo' checks whether pure functions are not called for > their side-effects and it's applied after optimizations so in the > above code, the code generated by destructuring-bind ends up optimized > to something that calls `car' without binding the result to _ because > it figured that _ is not used and just got rid of it without warning. > > So most likely the answers I give here aren't satisfactory to the OP, > since his real problem is probably different than (destructuring-bind > (_) x) and the solution for that problem is probably going to be > yet different. 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. But that trick only works for the non-lexical-binding case. 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".) It's perhaps easier to teach destructuring-bind the _ convention so that it can produce more direct code. 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. Helmut