unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* call with value
@ 2020-04-12 16:58 Stefan Israelsson Tampe
  2020-04-13  2:34 ` William ML Leslie
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Israelsson Tampe @ 2020-04-12 16:58 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

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.

This is implemented as

(call-with-values (lambda () r.h.s.)
   (case-lambda
      ((x) x)
      (x   x)))

This has nice semantics but is expensive. Many times we can prove that
r.h.s. has a single value return and we would like to be speed optimal for
this case. I do not think that the python compiler should do this analysis
or what do you think?

[-- Attachment #2: Type: text/html, Size: 1106 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-13  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 16:58 call with value Stefan Israelsson Tampe
2020-04-13  2:34 ` William ML Leslie

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).