From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Fix `get-string-n!' &i/o-decoding exception behavior Date: Mon, 12 Nov 2012 20:52:54 +0100 Message-ID: <87k3tqoay1.fsf@delenn.home.rotty.xx.vu> References: <1352332308-5191-1-git-send-email-a.rottmann@gmx.at> <874nkwa9bw.fsf@tines.lan> <87haow8004.fsf@delenn.home.rotty.xx.vu> <877gpr96qv.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1352749992 24840 80.91.229.3 (12 Nov 2012 19:53:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 Nov 2012 19:53:12 +0000 (UTC) Cc: guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Nov 12 20:53:21 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 1TY04P-0000Ar-FP for guile-devel@m.gmane.org; Mon, 12 Nov 2012 20:53:21 +0100 Original-Received: from localhost ([::1]:48171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TY04G-00073k-00 for guile-devel@m.gmane.org; Mon, 12 Nov 2012 14:53:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:53157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TY04A-00072j-9s for guile-devel@gnu.org; Mon, 12 Nov 2012 14:53:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TY047-0004DC-7P for guile-devel@gnu.org; Mon, 12 Nov 2012 14:53:06 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:38299) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TY046-0004D1-UH for guile-devel@gnu.org; Mon, 12 Nov 2012 14:53:03 -0500 Original-Received: (qmail invoked by alias); 12 Nov 2012 19:52:59 -0000 Original-Received: from 91-119-177-155.dynamic.xdsl-line.inode.at (EHLO cubox.home.rotty.xx.vu) [91.119.177.155] by mail.gmx.net (mp017) with SMTP; 12 Nov 2012 20:52:59 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX18pocEQdhgpdcvGbd8zn362RAMCCk92HA8mi7YbUl 7oLdcpCWCcI1P2 Original-Received: from delenn.home.rotty.xx.vu (delenn.home.rotty.xx.vu [IPv6:fdfb:599d:f328:2::6e]) by cubox.home.rotty.xx.vu (Postfix) with ESMTP id AD0DF16008C; Mon, 12 Nov 2012 20:52:54 +0100 (CET) Original-Received: by delenn.home.rotty.xx.vu (Postfix, from userid 1000) id 7D3C632002C; Mon, 12 Nov 2012 20:52:54 +0100 (CET) In-Reply-To: <877gpr96qv.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 11 Nov 2012 16:20:24 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 213.165.64.23 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:15161 Archived-At: Mark H Weaver writes: > 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? > OK, I'll give this approach a try; I suspect it will indeed result in the least churn. Regards, Rotty -- Andreas Rottmann --