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 11:24:31 -0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306160711 6638 80.91.229.12 (23 May 2011 14:25:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 14:25:11 +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 16:25:07 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 1QOW4B-0003hp-6b for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 16:25:07 +0200 Original-Received: from localhost ([::1]:60998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOW4A-0004Wy-M5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 10:25:06 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:50422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOW47-0004Ve-Jk for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 10:25:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOW46-00060P-GE for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 10:25:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOW46-0005zu-4I for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 10:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOW45-0002fK-TV; Mon, 23 May 2011 10:25:01 -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 14: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: Original-Received: via spool by 8711-submit@debbugs.gnu.org id=B8711.130616068210214 (code B ref 8711); Mon, 23 May 2011 14:25:01 +0000 Original-Received: (at 8711) by debbugs.gnu.org; 23 May 2011 14:24:42 +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 1QOW3l-0002eh-A3 for submit@debbugs.gnu.org; Mon, 23 May 2011 10:24:41 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOW3j-0002eV-AT for 8711@debbugs.gnu.org; Mon, 23 May 2011 10:24:40 -0400 Original-Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:40770 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QOW3d-00055m-Qs; Mon, 23 May 2011 10:24:34 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 2F3FB66131; Mon, 23 May 2011 11:24:31 -0300 (ART) In-Reply-To: (Lawrence Mitchell's message of "Mon, 23 May 2011 10:01:04 +0100") 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 10:25:01 -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:46656 Archived-At: >> There seems be no way to avoid a warning in code like this: >> ;; -*- lexical-binding: t -*- >> (eval-when-compile (require 'cl)) >> (defun foo (x) (destructuring-bind (_) x)) Hmm... the byte-compiler complains because the above gets turned into (let* ((--cl-rest-- x) (_ (if (= (length --cl-rest--) 1) (car --cl-rest--) (signal 'wrong-number-of-arguments (list nil (length --cl-rest--)))))) nil) which gets changes by byte-opt.el into (let* ((--cl-rest-- x)) (if (= (length --cl-rest--) 1) (car --cl-rest--) (signal 'wrong-number-of-arguments (list nil (length --cl-rest--)))) nil) And note that this is only done for a `nil' body (tho it can also be something like (progn nil) because that would be optimized to nil as well), and not for a body like `5' (although the optimization is just as valid for `5' as for nil). >> (defun bar (x) (destructuring-bind (_) x (ignore _))) (defun bar (x) (destructuring-bind (_) x (ignore nil))) works (because (ignore nil) happens not to be optimized to nil). > This latter is because cconv-analyse-use is not smart enough when > checking for use of variables starting with an underscore. > ;; -*- lexical-binding: t -*- > (let ((_ nil)) > (ignore _)) > => > Warning: variable `_' not left unused. > This despite ignore not touching it. 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. Stefan