guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple values passed as single argument to procedure


From: Mark H Weaver
Subject: Re: Multiple values passed as single argument to procedure
Date: Mon, 12 Jun 2017 23:09:21 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]