From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: doco scm_internal_catch Date: Tue, 26 Aug 2003 07:57:27 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87oeyde6yg.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1061872124 26312 80.91.224.253 (26 Aug 2003 04:28:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Aug 2003 04:28:44 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 26 06:28:40 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19rVRf-0005vJ-00 for ; Tue, 26 Aug 2003 06:28:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19rVLl-0001t5-31 for guile-devel@m.gmane.org; Tue, 26 Aug 2003 00:22:33 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19rVDJ-0006b8-9T for guile-devel@gnu.org; Tue, 26 Aug 2003 00:13:49 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19rVBl-0005PN-B7 for guile-devel@gnu.org; Tue, 26 Aug 2003 00:12:44 -0400 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19rV72-0002gq-KV for guile-devel@gnu.org; Tue, 26 Aug 2003 00:07:20 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h7PLw20J019373 for ; Tue, 26 Aug 2003 07:58:02 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h7PLw2kv008480 for ; Tue, 26 Aug 2003 07:58:02 +1000 (EST) Original-Received: from localhost (ppp74.dyn228.pacific.net.au [203.143.228.74]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h7PLvjos027008 for ; Tue, 26 Aug 2003 07:57:56 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19rPL8-0000k7-00; Tue, 26 Aug 2003 07:57:30 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2719 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2719 A few words adapted from throw.c for the end of the Catch node, and for the Lazy Catch node just after the lazy-catch / scm_lazy_catch definition. I'm not sure I quite follow the caveat about garbage collection of the data parameter. If an SCM_UNPACK is done to turn an SCM into a value for the data pointer parameter, is that in theory not going to be spotted by gc? Or is it merely that if the data pointer is to a malloced block or the like, that such an area is unknown to the gc? - C Function: SCM scm_internal_catch (SCM tag, scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, void *handler_data) The above `scm_catch' takes Scheme procedures as body and handler arguments. `scm_internal_catch' is an equivalent taking C functions. BODY is called as `BODY (BODY_DATA)' with a catch on exceptions of the given TAG type. If an exception is caught, HANDLER is called `HANDLER (HANDLER_DATA, KEY, ARGS)'. KEY and ARGS are the `SCM' key and argument list from the `throw'. BODY and HANDLER should have the following prototypes. `scm_t_catch_body' and `scm_t_catch_handler' are pointer typedefs for these. SCM body (void *data); SCM handler (void *data, SCM key, SCM args); The BODY_DATA and HANDLER_DATA parameters are passed to the respective calls so an application can communicate extra information to those functions. If the data consists of an `SCM' object, care should be taken that it isn't garbage collected while still required. If the `SCM' is a local C variable, one way to protect it is to pass a pointer to that variable as the data parameter, since the C compiler will then know the value must be held on the stack. Another way is to use `scm_remember_upto_here_1' (*note Remembering During Operations::). - C Function: SCM scm_internal_lazy_catch (SCM tag, scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, void *handler_data) The above `scm_lazy_catch' takes Scheme procedures as body and handler arguments. `scm_internal_lazy_catch' is an equivalent taking C functions. See `scm_internal_catch' (*note Catch::) for a description of the parameters, though the behaviour however of course follows `lazy-catch'. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel