From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Alf P. Steinbach" Newsgroups: gmane.emacs.help Subject: Re: How to exit out of a function ? what is try-catch-throw in terms of Program Counter Date: Mon, 05 Nov 2007 06:07:25 +0100 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <13it94l8vrcqfac@corp.supernews.com> 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=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1194241243 10872 80.91.229.12 (5 Nov 2007 05:40:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2007 05:40:43 +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 06:40:45 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 1IouhZ-0006OY-0P for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 06:40:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IouhO-0004Fu-DE for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 00:40:34 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!hq-usenetpeers.eweka.nl!81.171.88.9.MISMATCH!ramfeed2.eweka.nl!eweka.nl!lightspeed.eweka.nl!138.199.65.86.MISMATCH!sn-xt-ams-06!sn-xt-ams-05!sn-post-ams-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.lang.c,comp.lang.c++ User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051201 Thunderbird/1.5 Mnenhy/0.7.3.0 In-Reply-To: Original-X-Complaints-To: abuse@supernews.com Original-Lines: 48 Original-Xref: shelby.stanford.edu gnu.emacs.help:153538 comp.lang.c:830326 comp.lang.c++:955922 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:49019 Archived-At: * David Thompson: > 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. So? But also, what on Earth do you mean by a cross-thread longjmp? I implemented coroutines in terms of longjmp at the time that was popular, so the concepts involved are not unfamiliar to me. Yet I fail to envision what you could be talking about, especially as "fact". I think perhaps you're talking about restoring the full context (registers etc) of a moment in a thread's execution? >> 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. I don't know about ptheads cancellation, but other than that you're right. Visual C++ coordinates longjmp with C++ stack unwinding. g++, on the other hand, does not. Cheers, & hth., - Alf -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?