unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: William ML Leslie <william.leslie.ttg@gmail.com>
To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: call with value
Date: Mon, 13 Apr 2020 12:34:51 +1000	[thread overview]
Message-ID: <CAHgd1hFzrrWbow86ravWWc9Hp7jRBty4qJf_oXEi5=qOsS53ig@mail.gmail.com> (raw)
In-Reply-To: <CAGua6m18HEggROOMmCh_dZ6_StjJfsdR6w+M-BTM5cS=h6HuDg@mail.gmail.com>

On Mon, 13 Apr 2020 at 02:59, Stefan Israelsson Tampe
<stefan.itampe@gmail.com> wrote:
>
> I have this (on guile 3.0.0),
>
> (define (f x) (call-with-values (lambda () x) (case-lambda ((x) ...) (x ...)))))
>
> and the code does not simplify to (define (f x) x), why?
>
> It would be great to have guile optimize this as in python we have
>
> x=1,0
> => x=(1,0)
>
> And the great thing with python on guile is that we get the same behavior with (values 1 0) as a r.h.s. so that we get good interoperability between guile and python.
>

Hi Stis,

I'm not sure if I mentioned this to you earlier, but I'm worried that
this won't be a great user experience.  When a python function returns
a tuple, whether "implicitly" as part of the return statement or not,
the invoker still gets one tuple, and is free to unpack it.  If I were
to call a function that returned a 1-value tuple and instead it got
unpacked for me, I would be very confused.

Similarly, if a python function `f` returns a tuple and I invoke
`g(f(x))`, I expect g to receive one tuple; not a number of arguments.
I'd have to say `g(*f(x))` if I wanted it to receive the items as
argument values.

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.



      reply	other threads:[~2020-04-13  2:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12 16:58 call with value Stefan Israelsson Tampe
2020-04-13  2:34 ` William ML Leslie [this message]

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='CAHgd1hFzrrWbow86ravWWc9Hp7jRBty4qJf_oXEi5=qOsS53ig@mail.gmail.com' \
    --to=william.leslie.ttg@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=stefan.itampe@gmail.com \
    /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).