[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing multiple values from C

From: Ludovic Courtès
Subject: Re: Accessing multiple values from C
Date: Tue, 01 Nov 2011 23:57:25 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)


Julian Graham <address@hidden> 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

> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]