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 21:51:59 -0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306198395 30544 80.91.229.12 (24 May 2011 00:53:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 May 2011 00:53:15 +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 Tue May 24 02:53:08 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 1QOfrv-0005IH-8W for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 May 2011 02:53:07 +0200 Original-Received: from localhost ([::1]:48071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOfru-0000VL-MA for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 20:53:06 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOfrs-0000VG-5B for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 20:53:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOfrr-0008Cr-9r for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 20:53:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOfrr-0008Cn-3d for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 20:53:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QOfrq-0001L2-Dg; Mon, 23 May 2011 20:53:02 -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: Tue, 24 May 2011 00:53: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: Original-Received: via spool by 8711-submit@debbugs.gnu.org id=B8711.13061983315074 (code B ref 8711); Tue, 24 May 2011 00:53:02 +0000 Original-Received: (at 8711) by debbugs.gnu.org; 24 May 2011 00:52:11 +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 1QOfr1-0001Jn-0V for submit@debbugs.gnu.org; Mon, 23 May 2011 20:52:11 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QOfqy-0001Jb-Pj for 8711@debbugs.gnu.org; Mon, 23 May 2011 20:52:09 -0400 Original-Received: from 213-159-126-200.fibertel.com.ar ([200.126.159.213]:51590 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QOfqt-0004YS-5W; Mon, 23 May 2011 20:52:03 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 95FB5662FB; Mon, 23 May 2011 21:51:59 -0300 (ART) In-Reply-To: (Helmut Eller's message of "Mon, 23 May 2011 22:32:56 +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 20:53: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:46671 Archived-At: >> 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. > BTW, is there a good reason why we can't disallow setq on closed over > variables in Elisp? Yes and no: technically, we could, of course, but I'm not sure that's worth the trouble. I'm in favor of pure languages (e.g. I've local changes that make Emacs strings immutable, often install changes that reduce the use of setq, ...) but realistically Emacs Lisp won't get rid of setq any time soon. Now, why single out setq on closed over variables? Note that currently closures are used internally a lot more often than you'd think, since every condition-case, unwind-protect, and catch makes its body and branches into closures. Also it's common for lambda arguments to mapcar and mapc to use setq on some closed over variable used a sort of accumulator. > That kind of mutability seems like a bad idea in a > concurrent world. Emacs has a crapload of global state, so we won't be able to wiggle around global mutability problems. Maybe every bit helps, but I'm very much unconvinced. > Closures are a new feature so we could make a conscious decision not > to introduce the problematic mutable variables. But I also want it to be as easy as possible to turn valid dynbind Elisp code into valid lexbind code, so any additional restriction needs a very good justification. Stefan