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

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?

   Regards,
     Mark



  reply	other threads:[~2012-11-11 21:20 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 [this message]
2012-11-11 23:45       ` Mark H Weaver
2012-11-12 19:52       ` Andreas Rottmann

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=877gpr96qv.fsf@tines.lan \
    --to=mhw@netris.org \
    --cc=a.rottmann@gmx.at \
    --cc=guile-devel@gnu.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).