From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: Backtrace and enhanced catch Date: Wed, 01 Feb 2006 07:07:55 +1100 Message-ID: <87k6cgi2jo.fsf@zip.com.au> References: <200511301616.22258.bkorb@gnu.org> <87wthpkyan.fsf@ossau.uklinux.net> <43B69F41.6030509@xs4all.nl> <87hd8pb8o7.fsf@ossau.uklinux.net> <87lkxy3abo.fsf@ossau.uklinux.net> <877j9i31gc.fsf@ossau.uklinux.net> <87acebhf1o.fsf@ossau.uklinux.net> <871wyu8t5e.fsf@zip.com.au> <87k6cl8o5c.fsf@ossau.uklinux.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1138739185 18030 80.91.229.2 (31 Jan 2006 20:26:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 20:26:25 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jan 31 21:26:21 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F424t-0003KM-6u for guile-devel@m.gmane.org; Tue, 31 Jan 2006 21:26:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F4275-0001bK-U3 for guile-devel@m.gmane.org; Tue, 31 Jan 2006 15:28:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F41qc-0000xF-MG for guile-devel@gnu.org; Tue, 31 Jan 2006 15:11:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F41qZ-0000sP-EB for guile-devel@gnu.org; Tue, 31 Jan 2006 15:11:29 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F41qY-0000rM-8j for guile-devel@gnu.org; Tue, 31 Jan 2006 15:11:26 -0500 Original-Received: from [61.8.0.84] (helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F41p4-0006D9-Q6 for guile-devel@gnu.org; Tue, 31 Jan 2006 15:09:55 -0500 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87]) by mailout1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k0VK88Aa007396; Wed, 1 Feb 2006 07:08:09 +1100 Original-Received: from localhost (ppp2FCF.dyn.pacific.net.au [61.8.47.207]) by mailproxy2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k0VK849W027257; Wed, 1 Feb 2006 07:08:06 +1100 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1F41n9-0001mJ-00; Wed, 01 Feb 2006 07:07:55 +1100 Original-To: Neil Jerram Mail-Copies-To: never User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5642 Archived-At: Neil Jerram writes: > > an example? (c-lazy-catch #t (lambda () (mucho hairy data download using http, including continuations to suspend)) (lambda args (print-message "%s and %s went wrong" ...) ;; continue on connection or http protocol problems (including ;; http timeout), throw full error otherwise (if (not (or (eq? 'http (first args)) ;; my errors (gethost-error-try-again? args) ;; gethost errors (system-error-econn? args))) ;; ECONNREFUSED (apply throw args)))) The idea is the handler does some cleanup (print a message in this case) and then makes a decision about continuing or dying. If it's fatal then re-throw, and in that throw I'm wanting a full backtrace. If this was a plain `catch' then the re-throw loses the backtrace, and if it was a lazy-catch then you're not allowed to return, hence my c-lazy-catch which is a combination. The implementation isn't super-efficient, ;; lazy-catch, but with HANDLER allowed to return (define-public (c-lazy-catch key thunk handler) (catch 'c-lazy-catch (lambda () (lazy-catch key thunk (lambda args (throw 'c-lazy-catch (apply handler args))))) (lambda (key val) val))) I'm not sure how typical this is. It seems a reasonable desire, but maybe there's a better way to do it. I've fiddled about a bit with my overall error trap structure, from trapping each call to now a higher level overall catch. > I think it's non-negotiable that if someone has coded a (throw ...) > or an (error ...), execution cannot continue normally past that > throw or error Yes, that'd create havoc, I only meant continue after the `catch' / `lazy-catch' form. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel