unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: call with value
Date: Sun, 12 Apr 2020 18:58:46 +0200	[thread overview]
Message-ID: <CAGua6m18HEggROOMmCh_dZ6_StjJfsdR6w+M-BTM5cS=h6HuDg@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2020-04-12 16:58 UTC|newest]

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

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='CAGua6m18HEggROOMmCh_dZ6_StjJfsdR6w+M-BTM5cS=h6HuDg@mail.gmail.com' \
    --to=stefan.itampe@gmail.com \
    --cc=guile-devel@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).