From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: call with value Date: Sun, 12 Apr 2020 18:58:46 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e4de1105a31ae1a8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="120684"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Apr 12 18:59:16 2020 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jNfwx-000VGq-AN for guile-devel@m.gmane-mx.org; Sun, 12 Apr 2020 18:59:15 +0200 Original-Received: from localhost ([::1]:35214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNfww-00011O-0m for guile-devel@m.gmane-mx.org; Sun, 12 Apr 2020 12:59:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46756) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNfwk-000119-Ad for guile-devel@gnu.org; Sun, 12 Apr 2020 12:59:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jNfwj-0003WS-Cf for guile-devel@gnu.org; Sun, 12 Apr 2020 12:59:02 -0400 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:37004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jNfwj-0003Ur-3T for guile-devel@gnu.org; Sun, 12 Apr 2020 12:59:01 -0400 Original-Received: by mail-wm1-x335.google.com with SMTP id z6so7874028wml.2 for ; Sun, 12 Apr 2020 09:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=fZThkd3iFCYlX+wuvVvBQsRlE1F64mN5wzet78C+Gls=; b=LvRiFNoGjrp5LHjgy0mF41QYE696a8nE04NGYj+GLLAkwWR2wsX2LAVSRPGxByt2Di WGc+n+iCaeluS42zwoHwONNge+lKA4+P7ZYOanEwPvmFZCwF0Itd8wIOAvAbXTtwplaM SXydFy7eEmkj01hpcnI0XPDlAP3Ho+vyBLTN3kNdhmokjXK8TUT1W/geQ5D9xtwlFMJb wUVrKNFmyZmXUwaca8RuZrVGj35AH2B9gQbkEW4RN4tOvk9JMlgf/+sqLa44NXuyf4R8 pQS4uWEtp4b9v8mfUobi0fjqrtVm6qF+IPGDgPTSKZhKoCAP6za2F+AylnysOBcABk9z kMZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=fZThkd3iFCYlX+wuvVvBQsRlE1F64mN5wzet78C+Gls=; b=Aw+1xNe8x2iLWKHhgN7Y2L6c7m6nSTcp64nWpkDY9bjbb85i93dnRXrra8nt1Gsx2D FpZZPVDH+UJt91A9lwCDcpqt6g8L7B1pW8ZOdTrthV3CBbWFa85LBhOwCC/lMTsIGfNc SWmihCHAJGbc4KQIG/SDWA8X+j+DbqfmTjAUu02QSC/C6sG/Tg6rars+BAZPSaxxXtfd HhfmZYed0iFJtVBXL/SffpYACW7K/yIojx769PFrzym8FDx2mHGArMfgvl5jM6MwU5Am cOVQgNM0+OMiVQzSPda5cu/Gq1wh1J1CSco2jst91y8seoHkA1IK1L41y0Z/S2iV+knl sedg== X-Gm-Message-State: AGi0Pub1Pm0Nx7PdUnbZ/SejQZzqyp2AEpGQWDnSVou5OOoDl9Vio2k3 xzB57Gu44XbI7Gp5Z6GwL8/3FdiDxxqp2zEPScZVMA== X-Google-Smtp-Source: APiQypIG4vx5NR9DmOEXE3HPPi97ZfkhlxbblRo4zQTE9xdK0es36WsS8dF2PvmpiT6FUt6apGqAsMon2dfl4Yy8BWA= X-Received: by 2002:a1c:9ecb:: with SMTP id h194mr15712241wme.49.1586710737901; Sun, 12 Apr 2020 09:58:57 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20487 Archived-At: --000000000000e4de1105a31ae1a8 Content-Type: text/plain; charset="UTF-8" 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? --000000000000e4de1105a31ae1a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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), w= hy?

It would be great to have guile optimize this = as in python we have

x=3D1,0
=3D> x= =3D(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 g= et good interoperability between guile and python.

This is implemented as

(call-with-values=C2=A0(la= mbda () r.h.s.)
=C2=A0 =C2=A0(case-lambda=C2=A0
=C2=A0 = =C2=A0 =C2=A0 ((x) x)
=C2=A0 =C2=A0 =C2=A0 (x=C2=A0 =C2=A0x)))

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 shoul= d do this analysis or what do you think?




--000000000000e4de1105a31ae1a8--