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:59:50 +0100 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <13itc6tjt7vak46@corp.supernews.com> References: <1192913158.922454.108100@k35g2000prh.googlegroups.com> <13hl1rug786p1f2@corp.supernews.com> <13it94l8vrcqfac@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 1194244837 17596 80.91.229.12 (5 Nov 2007 06:40:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2007 06:40:37 +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 07:40:41 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 1IovdY-0006Av-7o for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 07:40:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IovdO-0004jl-04 for geh-help-gnu-emacs@m.gmane.org; Mon, 05 Nov 2007 01:40:30 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!news.glorb.com!sn-xt-sjc-05!sn-xt-sjc-09!sn-xt-sjc-07!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: <13it94l8vrcqfac@corp.supernews.com> Original-X-Complaints-To: abuse@supernews.com Original-Lines: 56 Original-Xref: shelby.stanford.edu gnu.emacs.help:153539 comp.lang.c:830334 comp.lang.c++:955926 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:49020 Archived-At: * Alf P. Steinbach: > * 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. Sorry, I didn't see the weasel-word "actually", which indicates a contradiction. When I wrote that you're right, that just meant that you supplied some extra info that wasn't incorrect. Cheers, - 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?