From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: About `catch' and `throw' Date: Fri, 21 Dec 2012 20:08:33 +0100 Organization: Informatimago Message-ID: <87zk17dxzi.fsf@kuiper.lan.informatimago.com> References: <20121221200001.891d30e881f25580089bbc5b@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1356116950 17721 80.91.229.3 (21 Dec 2012 19:09:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2012 19:09:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 20:09:25 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tm7y9-0004es-NF for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 20:09:17 +0100 Original-Received: from localhost ([::1]:40087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm7xv-0004B8-N5 for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 14:09:03 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm7xo-0004B3-8G for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 14:08:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm7xj-0007mS-Mq for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 14:08:56 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:55743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm7xj-0007mL-Fw for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 14:08:51 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Tm7xt-0004Kn-D4 for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 20:09:01 +0100 Original-Received: from cust-seco21th2-46-193-64-247.wb.wifirst.net ([46.193.64.247]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Dec 2012 20:09:01 +0100 Original-Received: from pjb by cust-seco21th2-46-193-64-247.wb.wifirst.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Dec 2012 20:09:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cust-seco21th2-46-193-64-247.wb.wifirst.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:NmFkM2I4ODg0MmY2MzNjNDI2Njc3NDYwM2U2YTY5YjAxN2MxODNhYg== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88286 Archived-At: Xue Fuqiao writes: > I'm reading the Emacs Lisp Reference Manual, and I met a problem. In the node 10.5.1(http://www.gnu.org/software/emacs/manual/html_node/elisp/Catch-and-Throw.html#Catch-and-Throw), it says: > > throw is used inside a catch, and jumps back to that catch. For example: > (defun foo-outer () > (catch 'foo > (foo-inner))) > (defun foo-inner () > ... > (if x > (throw 'foo t)) > ...) > > but the `throw' is used outside the `catch', I'm confused. Can anybody help? The point is that catch/throw is a dynamic mechanism, not a lexical one. So it is bad to say "outside", since this has a spacial conotation. throw can be used WHEN catch is executing, or WHEN it is not. If you call (throw 'something result) WHEN there's a (catch 'something …) executing, then the control will pass from the throw expression to the catch expression, and the catch expression will return the result passed to throw. It's only a question of time, of WHEN catch is being evaluated and WHEN throw is evaluated. I could talk you about block and return-from which are a lexical mechanism, with which what matters is WHERE the return-from is relative to the lexical scope defined by block, but the current implementation (even in emacs-24) is full of bugs. If you want, ask again on news:comp.lang.lisp and we'll tell you about catch/throw and block/return-from in Common Lisp. -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.