From: Mark H Weaver <mhw@netris.org>
To: David Kastrup <dak@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: Multiple values passed as single argument to procedure
Date: Mon, 12 Jun 2017 23:09:21 -0400 [thread overview]
Message-ID: <87d1a81t3y.fsf@netris.org> (raw)
In-Reply-To: <87h8zk1v3v.fsf@netris.org> (Mark H. Weaver's message of "Mon, 12 Jun 2017 22:26:12 -0400")
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
next prev parent reply other threads:[~2017-06-13 3:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-11 7:56 Multiple values passed as single argument to procedure Chris Marusich
2017-06-11 8:28 ` David Kastrup
2017-06-11 20:36 ` Mark H Weaver
2017-06-11 21:31 ` Mark H Weaver
2017-06-12 0:19 ` Chris Marusich
2017-06-12 4:25 ` Mark H Weaver
2017-06-12 8:19 ` Chris Marusich
2017-06-12 8:55 ` Neil Jerram
2017-06-12 9:48 ` Neil Jerram
2017-06-12 9:39 ` David Kastrup
2017-06-12 11:31 ` Mark H Weaver
2017-06-12 14:24 ` David Kastrup
2017-06-13 2:26 ` Mark H Weaver
2017-06-13 3:09 ` Mark H Weaver [this message]
2017-06-13 3:45 ` Mark H Weaver
2017-06-13 11:17 ` dsmich
2017-06-26 11:25 ` Alex Vong
-- strict thread matches above, loose matches on Subject: below --
2017-09-01 19:39 Chris Marusich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d1a81t3y.fsf@netris.org \
--to=mhw@netris.org \
--cc=dak@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).