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 C error handling Date: Sun, 04 May 2003 11:29:23 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87ptmzjy8c.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1052011854 25287 80.91.224.249 (4 May 2003 01:30:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 4 May 2003 01:30:54 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun May 04 03:30:52 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19C8L5-0006ZR-00 for ; Sun, 04 May 2003 03:30:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C8MD-0002QS-00 for guile-devel@m.gmane.org; Sat, 03 May 2003 21:32:01 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19C8LC-0001qU-00 for guile-devel@gnu.org; Sat, 03 May 2003 21:30:58 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19C8Ko-0001SJ-00 for guile-devel@gnu.org; Sat, 03 May 2003 21:30:35 -0400 Original-Received: from snoopy.pacific.net.au ([61.8.0.36]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19C8KR-00012b-00 for guile-devel@gnu.org; Sat, 03 May 2003 21:30:11 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) h441U8s7011690 for ; Sun, 4 May 2003 11:30:08 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h441U8Qg013444 for ; Sun, 4 May 2003 11:30:08 +1000 (EST) Original-Received: from localhost (ppp30.dyn228.pacific.net.au [203.143.228.30]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h441U6YZ022969 for ; Sun, 4 May 2003 11:30:06 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19C8Jh-0004Cg-00; Sun, 04 May 2003 11:29:25 +1000 Original-To: guile-devel@gnu.org User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2262 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2262 --=-=-= * scheme-control.texi (Handling Errors): Revise C support section to get index entries and clarify parameters. Remove scm_regex_error, no longer exists and wasn't available to applications. I hope I'm right that scm_regex_error is gone, it doesn't show up in a grep. Incidentally, is the regex-error error key described in the scheme section of this node be regular-expression-syntax, as per the `make-regexp' doco? Revised text: C Support --------- In the following C functions, SUBR and MESSAGE parameters can be `NULL' to give the `#f' described above. - Function: SCM scm_error (SCM key, char *subr, char *message, SCM args, SCM rest) Throw an error, as per `scm-error' above. - Function: void scm_syserror (char *subr) - Function: void scm_syserror_msg (char *subr, char *message, SCM args) Throw an error with key `system-error' and supply `errno' in the REST argument. For `scm_syserror' the message is generated using `strerror'. Of course care should be taken that any code in between the failing operation and the call to these routines doesn't change `errno'. - Function: void scm_num_overflow (char *subr) - Function: void scm_out_of_range (char *subr, SCM bad_value) - Function: void scm_wrong_num_args (SCM proc) - Function: void scm_wrong_type_arg (char *subr, int pos, SCM bad_value) - Function: void scm_memory_error (char *subr) Throw an error with the various keys described above. For `scm_wrong_num_args', PROC should be a Scheme symbol which is the name of the procedure incorrectly invoked. Exception handlers can also be installed from C, using `scm_internal_catch', `scm_lazy_catch', or `scm_stack_catch' from `libguile/throw.c'. These have not yet been documented, but the source contains some useful comments. --=-=-= Content-Disposition: attachment; filename=scheme-control.texi.c-errors.diff --- scheme-control.texi.~1.6.~ 2003-05-04 11:02:44.000000000 +1000 +++ scheme-control.texi 2003-05-04 11:24:15.000000000 +1000 @@ -934,41 +934,38 @@ @subsection C Support -SCM scm_error (SCM key, char *subr, char *message, SCM args, SCM rest) +In the following C functions, @var{SUBR} and @var{MESSAGE} parameters +can be @code{NULL} to give the @code{#f} described above. -Throws an error, after converting the char * arguments to Scheme strings. -subr is the Scheme name of the procedure, NULL is converted to #f. -Likewise a NULL message is converted to #f. - -The following procedures invoke scm_error with various error keys and -arguments. The first three call scm_error with the system-error key -and automatically supply errno in the "rest" argument: scm_syserror -generates messages using strerror. Care should be taken that the errno -value is not reset (e.g. due to an interrupt). - -@itemize @bullet -@item -void scm_syserror (char *subr); -@item -void scm_syserror_msg (char *subr, char *message, SCM args); -@item -void scm_num_overflow (char *subr); -@item -void scm_out_of_range (char *subr, SCM bad_value); -@item -void scm_wrong_num_args (SCM proc); -@item -void scm_wrong_type_arg (char *subr, int pos, SCM bad_value); -@item -void scm_memory_error (char *subr); -@item -static void scm_regex_error (char *subr, int code); (only used in rgx.c). -@end itemize +@deftypefun SCM scm_error (SCM key, char *subr, char *message, SCM args, SCM rest) +Throw an error, as per @code{scm-error} above. +@end deftypefun + +@deftypefun void scm_syserror (char *subr) +@deftypefunx void scm_syserror_msg (char *subr, char *message, SCM args) +Throw an error with key @code{system-error} and supply @code{errno} in +the @var{rest} argument. For @code{scm_syserror} the message is +generated using @code{strerror}. + +Of course care should be taken that any code in between the failing +operation and the call to these routines doesn't change @code{errno}. +@end deftypefun + +@deftypefun void scm_num_overflow (char *subr) +@deftypefunx void scm_out_of_range (char *subr, SCM bad_value) +@deftypefunx void scm_wrong_num_args (SCM proc) +@deftypefunx void scm_wrong_type_arg (char *subr, int pos, SCM bad_value) +@deftypefunx void scm_memory_error (char *subr) +Throw an error with the various keys described above. + +For @code{scm_wrong_num_args}, @var{proc} should be a Scheme symbol +which is the name of the procedure incorrectly invoked. +@end deftypefun Exception handlers can also be installed from C, using -scm_internal_catch, scm_lazy_catch, or scm_stack_catch from -libguile/throw.c. These have not yet been documented, however the -source contains some useful comments. +@code{scm_internal_catch}, @code{scm_lazy_catch}, or +@code{scm_stack_catch} from @file{libguile/throw.c}. These have not +yet been documented, but the source contains some useful comments. @c Local Variables: --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--