guile-devel
[Top][All Lists]
Advanced

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

Re: call with value


From: William ML Leslie
Subject: Re: call with value
Date: Mon, 13 Apr 2020 12:34:51 +1000

On Mon, 13 Apr 2020 at 02:59, Stefan Israelsson Tampe
<address@hidden> 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 via email to

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