From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.user Subject: Re: Multiple values passed as single argument to procedure Date: Mon, 12 Jun 2017 16:24:25 +0200 Message-ID: <87h8zl7086.fsf@fencepost.gnu.org> References: <87mv9fnejc.fsf@gmail.com> <87k24i2rev.fsf@netris.org> <87zidexdjw.fsf@gmail.com> <87a85d3k9n.fsf@netris.org> <87mv9dy5wb.fsf@gmail.com> <87mv9d7dfu.fsf@fencepost.gnu.org> <87wp8h1lyh.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1497277518 8072 195.159.176.226 (12 Jun 2017 14:25:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Jun 2017 14:25:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 12 16:25:11 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 1dKQHC-0001Vp-FF for guile-user@m.gmane.org; Mon, 12 Jun 2017 16:25:06 +0200 Original-Received: from localhost ([::1]:38401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQHH-0004rc-Oj for guile-user@m.gmane.org; Mon, 12 Jun 2017 10:25:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQGj-0004pQ-Mk for guile-user@gnu.org; Mon, 12 Jun 2017 10:24:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKQGg-0006Z9-FI for guile-user@gnu.org; Mon, 12 Jun 2017 10:24:37 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKQGg-0006Z4-Bp; Mon, 12 Jun 2017 10:24:34 -0400 Original-Received: from tmo-110-50.customers.d1-online.com ([80.187.110.50]:9188 helo=lola) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dKQGe-0000xH-GJ; Mon, 12 Jun 2017 10:24:34 -0400 In-Reply-To: <87wp8h1lyh.fsf@netris.org> (Mark H. Weaver's message of "Mon, 12 Jun 2017 07:31:34 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:13830 Archived-At: Mark H Weaver writes: > I'm sorry David, but _everything_ that you wrote below is incorrect. Well, let me try again. It's not all that easy to understand. > David Kastrup writes: > >> Chris Marusich writes: >> >>> I think I'm missing something here. In (list (f)), the call to f >>> certainly looks like it's happening at a position that one might >>> intuitively call a "tail" position. >> >> It is, > > No it isn't. > >> but list does not take multiple values > > Yes it does. 'list' accepts an arbitrary number of values > (arguments). In my book, multiple values/arguments are different things but I admit that this is a quagmire to me and strictly speaking what I call "multiple values" (namely the unmitigated return value from calling values) never occurs in the position of an argument (at least when not looking at the C API and/or Guile 1.x). dak@lola:/usr/local/tmp/lilypond$ guile-2.0 GNU Guile 2.0.13 Copyright (C) 1995-2016 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (list (values 1 2 3)) $1 = (1) scheme@(guile-user)> >> and thus discards additional values returned by f. > > 'list' does not discard anything. The additional values are discarded > before 'list' is called. Ok. Because a function call cannot take multiple values. It does take multiple _arguments_. A function call can appear to return multiple values by using call/cc (which is essentially what (values ...) does) and the construct call-with-values can salvage them as long as they are only passed through tail calls (or rather tail returns): (call-with-values (lambda () (call/cc (lambda (c) (c 1 2 3)))) list) => (1 2 3) Basically call-with-values is a mechanism that lets the continuation delivered by call/cc be a function accepting multiple arguments. An ordinary function call doesn't. > I will try to clarify all of this in another message. Well, I probably messed up things a whole lot more now. But at least it should be an excellent opportunity for correcting the half-truths and misconceptions that Scheme's procedure/continuation model might inspire in people (like me) without a firm grasp of its concepts. -- David Kastrup