From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Multiple values passed as single argument to procedure Date: Sun, 11 Jun 2017 16:36:08 -0400 Message-ID: <87k24i2rev.fsf@netris.org> References: <87mv9fnejc.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1497213405 4890 195.159.176.226 (11 Jun 2017 20:36:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Jun 2017 20:36:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-user@gnu.org To: Chris Marusich Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jun 11 22:36:42 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dK9bG-00012b-7f for guile-user@m.gmane.org; Sun, 11 Jun 2017 22:36:42 +0200 Original-Received: from localhost ([::1]:35120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dK9bL-0006qo-Dy for guile-user@m.gmane.org; Sun, 11 Jun 2017 16:36:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dK9az-0006qH-Lx for guile-user@gnu.org; Sun, 11 Jun 2017 16:36:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dK9au-0000D9-Pv for guile-user@gnu.org; Sun, 11 Jun 2017 16:36:25 -0400 Original-Received: from world.peace.net ([50.252.239.5]:42466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dK9au-0000Cw-Lh for guile-user@gnu.org; Sun, 11 Jun 2017 16:36:20 -0400 Original-Received: from pool-72-93-31-241.bstnma.east.verizon.net ([72.93.31.241] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dK9at-00012W-GG; Sun, 11 Jun 2017 16:36:19 -0400 In-Reply-To: <87mv9fnejc.fsf@gmail.com> (Chris Marusich's message of "Sun, 11 Jun 2017 00:56:23 -0700") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 50.252.239.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.user:13815 Archived-At: Chris Marusich writes: > I've noticed that when one passes multiple values as a single argument > to a procedure, only the first value gets used. Is this expected? Yes. Scheme has no concept of a "multiple values" object that can be given a single name, or passed as a single argument to a procedure. Returning multiple values from a procedure is analogous to passing multiple arguments to a procedure. Use 'call-with-values', 'let-values', or 'receive' to call a procedure that returns multiple values (or no values). If you do not use one of the above forms (or a macro that expands to one of them) to call a procedure that returns multiple values, then Guile will discard all but the first result. Note that this is a Guile-specific extension. Other Scheme implementations may behave differently (e.g. report an error) if multiple values (or no values) are returned to a procedure call that was not done using one of the forms listed above. Mark PS: I should mention that Guile does indeed have a "multiple values" object at the C level only, to allow C code to return or accept multiple values without uglifying the C calling convention for Scheme procedures. This is to work around the fact that C does not support returning multiple values from a function.