unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-user@gnu.org
Subject: Re: Accessing multiple values from C
Date: Tue, 01 Nov 2011 23:57:25 +0100	[thread overview]
Message-ID: <87fwi7cuy2.fsf@gnu.org> (raw)
In-Reply-To: CANdC_RDgPAB_=Cq88-ecGJz4W-YJTUUJFhpXJ6Zs7p2nQzrcYQ@mail.gmail.com

Hi,

Julian Graham <joolean@gmail.com> skribis:

> I was playing around with some C code that uses the new R6RS
> bytevector ports, and I noticed that there doesn't seem to be an easy
> way (a la `let-values' or `receive') to access multiple return values
> from C.  I've resorted to doing:
>
>   scm_struct_ref (foo, SCM_INUM0);
>
> ...which is almost certainly not future-proof.  All I want to do is
> access these values as a pair or list.

Values were already structs in 1.8, so that’s OK.

Perhaps this should be documented though, and C accessors could be
provided.

> Is there a Right Way to do that?

Yes: write Scheme code!  :-)

In 1.8 multiple-values were always a struct, which had to be allocated
each time multiple values were returned.  In 2.0 it’s a struct only if
it has to cross the Scheme/C boundary–otherwise the values are stored on
the VM stack.

Thanks,
Ludo’.




  reply	other threads:[~2011-11-01 22:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 15:34 Accessing multiple values from C Julian Graham
2011-11-01 22:57 ` Ludovic Courtès [this message]
2012-01-09 18:54 ` Andy Wingo
2012-01-09 19:00   ` Julian Graham
2012-01-12  4:50     ` Julian Graham
2012-01-15 21:47       ` Ludovic Courtès
2012-01-16  9:05         ` Andy Wingo
2012-01-18  3:15       ` Mark H Weaver
2012-01-18 16:20         ` Andy Wingo
2012-01-18 20:19         ` Ludovic Courtès
2012-01-18 21:01           ` Mark H Weaver
2012-01-18 21:44             ` Ludovic Courtès
2012-01-18 21:47             ` Mark H Weaver
2012-01-18 23:06               ` Mark H Weaver
2012-01-18 21:01           ` Julian Graham

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=87fwi7cuy2.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-user@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).