unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andreas Rottmann <a.rottmann@gmx.at>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Fix `get-string-n!' &i/o-decoding exception behavior
Date: Mon, 12 Nov 2012 20:52:54 +0100	[thread overview]
Message-ID: <87k3tqoay1.fsf@delenn.home.rotty.xx.vu> (raw)
In-Reply-To: <877gpr96qv.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 11 Nov 2012 16:20:24 -0500")

Mark H Weaver <mhw@netris.org> writes:

> Andreas Rottmann <a.rottmann@gmx.at> writes:
>
>> Mark H Weaver <mhw@netris.org> 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 -- <http://rotty.xx.vu/>



      parent reply	other threads:[~2012-11-12 19:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 23:51 [PATCH] Fix `get-string-n!' &i/o-decoding exception behavior Andreas Rottmann
2012-11-11  7:26 ` Mark H Weaver
2012-11-11 18:31   ` Andreas Rottmann
2012-11-11 21:20     ` Mark H Weaver
2012-11-11 23:45       ` Mark H Weaver
2012-11-12 19:52       ` Andreas Rottmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3tqoay1.fsf@delenn.home.rotty.xx.vu \
    --to=a.rottmann@gmx.at \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).