From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#8711: 24.0.50; binding _ to unused values with lexical-binding Date: Thu, 2 Jun 2011 13:17:56 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1307013568 5249 80.91.229.12 (2 Jun 2011 11:19:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2011 11:19:28 +0000 (UTC) Cc: 8711@debbugs.gnu.org, Helmut Eller To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 02 13:19:23 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 1QS5vu-0004xr-7F for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Jun 2011 13:19:22 +0200 Original-Received: from localhost ([::1]:38121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS5vt-0000sj-8t for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Jun 2011 07:19:21 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:47607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS5vd-0000s4-M2 for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2011 07:19:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QS5vb-0003rY-8Z for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2011 07:19:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QS5va-0003r5-QY for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2011 07:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QS5vZ-00020j-U6; Thu, 02 Jun 2011 07:19:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jun 2011 11:19: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.13070135247684 (code B ref 8711); Thu, 02 Jun 2011 11:19:01 +0000 Original-Received: (at 8711) by debbugs.gnu.org; 2 Jun 2011 11:18:44 +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 1QS5vH-0001zs-Ez for submit@debbugs.gnu.org; Thu, 02 Jun 2011 07:18:43 -0400 Original-Received: from mail-yx0-f172.google.com ([209.85.213.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QS5vF-0001zb-Np for 8711@debbugs.gnu.org; Thu, 02 Jun 2011 07:18:42 -0400 Original-Received: by yxk30 with SMTP id 30so296354yxk.3 for <8711@debbugs.gnu.org>; Thu, 02 Jun 2011 04:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=6VXGV6o9hXFw0ElsraqeaEoo/2tz0wQ131jkC1hSLd8=; b=FYi++23eh5M1ZEsFJLgya+OSqYFxmUbuuKdoVgX7adYFF1P75L28GcACl8cnrgDivm QzpcxW2Lv09LVgWH2m1qZOnCoocKvh6pCqvEUtRaLdOqdAASYLAbd/VudomUaiy5cu0t gJ9s9j4DtoQZJkmjRWwNuAE/578e7vsE+VX3w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=QiScWFbGj87yaQbBaPS6S82Hklch7jFnoKau6ZVxpaz/6GBIcPUADKdTIVVUzZHZOd 43sY4tge+E3adUDWjNSEaRWx2xkVomzMU72yK1UbSAWk9MDKpv+Wu8RRY/2PVJ6rZxw+ it/7rRJpU2iwTT/iHiQwinckVVoWjzmyaDk8s= Original-Received: by 10.236.182.103 with SMTP id n67mr719746yhm.26.1307013516117; Thu, 02 Jun 2011 04:18:36 -0700 (PDT) Original-Received: by 10.146.82.11 with HTTP; Thu, 2 Jun 2011 04:17:56 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 02 Jun 2011 07:19: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:46883 Archived-At: Speaking of unexpected warnings in lexical code: (let (new-list) (dolist (item list (nreverse new-list)) (when (not (funcall predicate item)) (setq new-list (cons item new-list))))) In toplevel form: doc-view.el:614:1:Warning: Unused lexical variable `item' Wrote c:/emacs/trunk/lisp/doc-view.elc but it does not happen if the RESULT of `dolist' is moved outside: (let (new-list) (dolist (item list) (when (not (funcall predicate item)) (setq new-list (cons item new-list)))) (nreverse new-list)) Apparently, the macroexpansion of `dolist' invokes RESULT as (setq VAR nil) RESULT or, in the cl-macs `dolist', as (let ((VAR nil)) RESULT) which I suppose has been doing for decades, but is still a bit strange. The docstring for `dolist' does not say that VAR is set to nil before computing RESULT. If computing RESULT needed the last VAR, the current code precludes it (unless it requires VAR to be nil, of course ;-) And, if computing RESULT requieres an outside VAR, the programmer is going to be forced to use this anyway: (let ((VAR 'myval)) (dolist (VAR mylist) ...) (compute-my-result VAR)) ;; with the let-bound VAR, not the dolist-bound one so setting it to nil in the (dolist (VAR LIST RESULT) ...) case does not bring any clear benefit, even in the non-lexical case. Or am I missing something obvious?