From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Thompson Newsgroups: gmane.emacs.help Subject: Re: How to exit out of a function ? what is try-catch-throw in terms of Program Counter Date: Sun, 04 Nov 2007 23:02:22 GMT Organization: Poor Message-ID: References: <1192913158.922454.108100@k35g2000prh.googlegroups.com> <13hl1rug786p1f2@corp.supernews.com> 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 1194249267 27792 80.91.229.12 (5 Nov 2007 07:54:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2007 07:54:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 05 08:54:31 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Iown0-0000lY-Fi for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 08:54:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iowmq-0003B5-27 for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 02:54:20 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc02.POSTED!7c706d3b!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.lang.c,comp.lang.c++ X-Newsreader: Forte Agent 3.3/32.846 Original-Lines: 26 Original-NNTP-Posting-Host: 151.204.5.34 Original-X-Complaints-To: abuse@verizon.net Original-X-Trace: trnddc02 1194217342 151.204.5.34 (Sun, 04 Nov 2007 18:02:22 EST) Original-NNTP-Posting-Date: Sun, 04 Nov 2007 18:02:22 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:153531 comp.lang.c:830298 comp.lang.c++:955906 X-Mailman-Approved-At: Mon, 05 Nov 2007 02:54:04 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49021 Archived-At: On Sun, 21 Oct 2007 00:55:53 +0200, "Alf P. Steinbach" wrote: > * gnuist006@gmail.com: > > NOTE: I am really afraid of try-catch-throw. I have never been > > able to understand it since it does not exist in C and I cant > > really visualize the construct in terms of C. > > The closest equivalent in C would be a 'longjmp'. However, a C++ > exception is more limited, in that it will only jump up the call chain, C longjmp/setjmp also is only guaranteed to work up the stack; the fact that _some_ implementations can work cross-stack and in particular cross-thread is not standard nor portable. > and it's more powerful, in that it will destroy local objects as it does > so. Also, if you use 'longjmp' in C++ you're practically doomed (unless > you use it to jump between co-routines with their own stacks), because > 'longjmp' doesn't destroy local objects. > Actually it's Undefined Behavior; a good quality C++ implementation CAN coordinate longjmp, and also pthreads cancellation, with exceptions to destruct locals cleanly -- but it's not required. - formerly david.thompson1 || achar(64) || worldnet.att.net