From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harald Hanche-Olsen Newsgroups: gmane.emacs.devel Subject: Re: Why are there two dolist? Date: Tue, 11 Aug 2009 21:24:23 -0400 (EDT) Message-ID: <20090811.212423.254477990.hanche@math.ntnu.no> References: <20090811.202730.45673955.hanche@math.ntnu.no> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1250040290 25657 80.91.229.12 (12 Aug 2009 01:24:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2009 01:24:50 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 12 03:24:43 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mb2a0-0000NA-Gx for ged-emacs-devel@m.gmane.org; Wed, 12 Aug 2009 03:24:40 +0200 Original-Received: from localhost ([127.0.0.1]:51519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mb2Zy-0006x8-Gp for ged-emacs-devel@m.gmane.org; Tue, 11 Aug 2009 21:24:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mb2Zt-0006wz-Ef for emacs-devel@gnu.org; Tue, 11 Aug 2009 21:24:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mb2Zp-0006wg-Q6 for emacs-devel@gnu.org; Tue, 11 Aug 2009 21:24:33 -0400 Original-Received: from [199.232.76.173] (port=35402 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mb2Zp-0006wd-Nv for emacs-devel@gnu.org; Tue, 11 Aug 2009 21:24:29 -0400 Original-Received: from abel.math.ntnu.no ([129.241.15.50]:52189) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mb2Zp-0003nQ-8Q for emacs-devel@gnu.org; Tue, 11 Aug 2009 21:24:29 -0400 Original-Received: (qmail 1420 invoked from network); 12 Aug 2009 01:24:26 -0000 Original-Received: from gauss.math.ntnu.no (HELO localhost) (hanche@129.241.15.102) by abel.math.ntnu.no with ESMTPA; 12 Aug 2009 01:24:26 -0000 In-Reply-To: X-URL: http://www.math.ntnu.no/~hanche/ X-Mailer: Mew version 6.2.51 on Emacs 23.0.94 / Mule 6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114116 Archived-At: + Lennart Borgman : > I do not understand your code above, but is not the conclusion that > the cl-macs.el version does not do what it is supposed to do? Yeah, at least as far as the lexically-scoped claim goes. > What value does it have then? At least in simpler usage, it does provide a block that return-from can use for a non-local exit, so it has some value. Actually, the bug seems to be in block, not in dolist. My example was perhaps overly complex. Here is a simpler example, using only two nested blocks, both named b: (block b (flet ((f (x) (return-from b x))) (list 'inner-block-returned (block b (f 42))))) In common lisp, the innermost call (f 42) executes a return-from that is lexically inside the outer block but not inside the inner one, so the value 42 is returned from the outer block. In elisp, on the other hand, the return-from inside foo causes the inner block to return 42, so the flet, and hence the outer block, returns instead the list (inner-block-returned 42). This seems to me to flatly contradict what is said about lexical scoping in the docstring of block. Oh, but wait: Looking at the code for block, I begin to suspect that byte compilation might make a difference. And indeed it does: (defun foo () (block b (flet ((f (x) (return-from b x))) (list 'inner-block-returned (block b (f 'bar)))))) (foo) ; => (inner-block-returned bar) (byte-compile 'foo) (foo) ; => bar So byte-compiling a block produces the expected result. Oh well, I guess this is just one more wart on the cl package. (It has a few, but I find it useful anyhow.) I still think that inadvertently using the cl version of dolist cannot possibly harm any elisp code that does not otherwise rely on cl. - Harald