From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Accessing multiple values from C Date: Tue, 01 Nov 2011 23:57:25 +0100 Message-ID: <87fwi7cuy2.fsf@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1320188267 10924 80.91.229.12 (1 Nov 2011 22:57:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2011 22:57:47 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Nov 01 23:57:44 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RLNH5-0000He-Fx for guile-user@m.gmane.org; Tue, 01 Nov 2011 23:57:43 +0100 Original-Received: from localhost ([::1]:59905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLNH5-0006G4-1u for guile-user@m.gmane.org; Tue, 01 Nov 2011 18:57:43 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLNH1-0006Fw-9q for guile-user@gnu.org; Tue, 01 Nov 2011 18:57:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLNH0-0001eP-4z for guile-user@gnu.org; Tue, 01 Nov 2011 18:57:39 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:51686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLNGz-0001eJ-Tj for guile-user@gnu.org; Tue, 01 Nov 2011 18:57:38 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RLNGz-0000Fc-6s for guile-user@gnu.org; Tue, 01 Nov 2011 23:57:37 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Nov 2011 23:57:37 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Nov 2011 23:57:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 11 Brumaire an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) Cancel-Lock: sha1:ejpmW1pFl5b8SbTjhRMat2n74Ss= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8927 Archived-At: Hi, Julian Graham 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’.