From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Fix `get-string-n!' &i/o-decoding exception behavior Date: Sun, 11 Nov 2012 16:20:24 -0500 Message-ID: <877gpr96qv.fsf@tines.lan> References: <1352332308-5191-1-git-send-email-a.rottmann@gmx.at> <874nkwa9bw.fsf@tines.lan> <87haow8004.fsf@delenn.home.rotty.xx.vu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1352668864 2668 80.91.229.3 (11 Nov 2012 21:21:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 11 Nov 2012 21:21:04 +0000 (UTC) Cc: guile-devel@gnu.org To: Andreas Rottmann Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Nov 11 22:21:15 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TXexu-0007Dc-Kv for guile-devel@m.gmane.org; Sun, 11 Nov 2012 22:21:14 +0100 Original-Received: from localhost ([::1]:58679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXexl-0002uM-5g for guile-devel@m.gmane.org; Sun, 11 Nov 2012 16:21:05 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXexf-0002oS-RL for guile-devel@gnu.org; Sun, 11 Nov 2012 16:21:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TXexc-0003Ot-NC for guile-devel@gnu.org; Sun, 11 Nov 2012 16:20:59 -0500 Original-Received: from world.peace.net ([96.39.62.75]:34886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TXexc-0003Oj-Io for guile-devel@gnu.org; Sun, 11 Nov 2012 16:20:56 -0500 Original-Received: from turntable.mit.edu ([18.160.0.29] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TXexU-0002Qn-5M; Sun, 11 Nov 2012 16:20:48 -0500 In-Reply-To: <87haow8004.fsf@delenn.home.rotty.xx.vu> (Andreas Rottmann's message of "Sun, 11 Nov 2012 19:31:23 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15157 Archived-At: Andreas Rottmann writes: > Mark H Weaver writes: > >> Why not leave the API as-is, and in the event of an error, just raise >> the proper R6RS exception from within 'scm_get_string_n_x'? >> > The problem here is that we have no easy way to raise R6RS exceptions > from C code, AFAICT. It is certainly possible, but if it involves > convoluted code of doing imports of condition types and appropriate > constructors, then constructing a proper invocation, all in C, I'd > rather avoid it. It's not that bad. In Guile 2.0 we have some convenient procedures for accessing arbitrary Scheme variables from C. Looking at your patch, I see that if '%get-string-n!' returned an error, then you did: (raise (make-i/o-decoding-error port)) This can be written in C as follows: scm_call_1 (scm_c_public_ref ("rnrs exceptions", "raise"), scm_call_1 (scm_c_public_ref ("rnrs io ports", "make-i/o-decoding-error"))); Alternatively, you could write one or more private helper procedures in Scheme to raise R6RS exceptions, and call those private helpers from C using 'scm_c_private_ref' instead of 'scm_c_public_ref'. What do you think? Regards, Mark