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: Mon, 12 Jun 2017 23:09:21 -0400 Message-ID: <87d1a81t3y.fsf@netris.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> <87h8zl7086.fsf@fencepost.gnu.org> <87h8zk1v3v.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1497323415 11543 195.159.176.226 (13 Jun 2017 03:10:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Jun 2017 03:10:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-user@gnu.org To: David Kastrup Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Jun 13 05:10:12 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 1dKcDb-0002nB-MQ for guile-user@m.gmane.org; Tue, 13 Jun 2017 05:10:11 +0200 Original-Received: from localhost ([::1]:40908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKcDg-0000eW-Pc for guile-user@m.gmane.org; Mon, 12 Jun 2017 23:10:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKcD4-0000WT-Bi for guile-user@gnu.org; Mon, 12 Jun 2017 23:09:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKcD1-0002DX-7D for guile-user@gnu.org; Mon, 12 Jun 2017 23:09:38 -0400 Original-Received: from world.peace.net ([50.252.239.5]:44407) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKcD1-0002CG-2J; Mon, 12 Jun 2017 23:09:35 -0400 Original-Received: from pool-72-93-33-54.bstnma.east.verizon.net ([72.93.33.54] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dKcCz-0008Gu-RI; Mon, 12 Jun 2017 23:09:34 -0400 In-Reply-To: <87h8zk1v3v.fsf@netris.org> (Mark H. Weaver's message of "Mon, 12 Jun 2017 22:26:12 -0400") 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:13833 Archived-At: In the discussion about continuation passing style, I forgot to explain the semantics of when and how Guile discards extra return values. It's very simple: I wrote: > Here's what (lambda () (list (f 1) (f 2) (f 3))) looks like in CPS, > using the same evaluation order as I chose above: > > (lambda (outer-k) > (f^ 2 (lambda (y) > (f^ 1 (lambda (x) > (f^ 3 (lambda (z) > (list^ x y z outer-k)))))))) In the CPS examples, I modelled these normal "unary" continuations as unary procedures of the form: (lambda (x) ...) In Guile, these "unary" continuations are not truly unary. Instead, they can be modeled roughly as procedures of this form: (lambda (x . _) ...) Where '_' does not occur free in the body. So, to model Guile's behavior in CPS, the example above becomes: (lambda (outer-k) (f^ 2 (lambda (y . _) (f^ 1 (lambda (x . _) (f^ 3 (lambda (z . _) (list^ x y z outer-k)))))))) Mark