From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: About `catch' and `throw' Date: Fri, 21 Dec 2012 09:03:19 -0800 Message-ID: <6EB1418B063C4F8CAFA179007459A7A5@us.oracle.com> References: <20121221200001.891d30e881f25580089bbc5b@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1356109421 15135 80.91.229.3 (21 Dec 2012 17:03:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2012 17:03:41 +0000 (UTC) To: "'Xue Fuqiao'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 18:03:56 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 1Tm60o-0001yI-Rn for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 18:03:54 +0100 Original-Received: from localhost ([::1]:39590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm60b-0004pJ-2H for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Dec 2012 12:03:41 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm60T-0004oD-0F for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 12:03:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tm60L-0005uS-Va for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 12:03:32 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:24676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tm60L-0005uM-PC for help-gnu-emacs@gnu.org; Fri, 21 Dec 2012 12:03:25 -0500 Original-Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qBLH3NU7031797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Dec 2012 17:03:23 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qBLH3MHa025248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Dec 2012 17:03:23 GMT Original-Received: from abhmt111.oracle.com (abhmt111.oracle.com [141.146.116.63]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id qBLH3MZG004312; Fri, 21 Dec 2012 11:03:22 -0600 Original-Received: from dradamslap1 (/71.202.147.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Dec 2012 09:03:22 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <20121221200001.891d30e881f25580089bbc5b@gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac3fmN9rW+xtHlAoQcGG9FQI7RoMmQAAlbpw X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:88279 Archived-At: > I'm reading the Emacs Lisp Reference Manual, and I met a > problem. In the node `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? It's about dynamic extent (scope, if you like) vs lexical scope. It should perhaps not say "inside", as that is a bit ambiguous. It really means that the `throw' is evaluated during the evaluation of the sexp inside the `catch'. The `throw' need not be lexically inside the `catch'. During the evaluation of code that is lexically inside the `catch', a `throw' that is evaluated throws back to that `catch'. And if there is more than one `catch' with the same label then it throws to the one that is lexically nearest (i.e., innermost, outside the `throw'), which is also the most recent. This part of the text should make it clear: "The `throw' need not appear lexically within the `catch' that it jumps to. It can equally well be called from another function called within the `catch'. As long as the `throw' takes place chronologically after entry to the `catch', and chronologically before exit from it, it has access to that `catch'." That last sentence says it better than I have said it here. It's really about dynamic extent ("chronologically"), not lexical scope.