From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id eEpyGyDdB2TQsAAASxT56A (envelope-from ) for ; Wed, 08 Mar 2023 01:56:00 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OLpvGyDdB2RqagEA9RJhRA (envelope-from ) for ; Wed, 08 Mar 2023 01:56:00 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B377116A6B for ; Wed, 8 Mar 2023 01:55:59 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.de header.s=2017 header.b="mucb2ex/"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678236960; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=tO704NrCxCd6w1VwvS9qNzt+JSTTnWbKpkn0WYc6sOA=; b=jHIq9EsM2/pGZ3YxbUMjwkvOd2zFNp+OVBHS4k61CBtzFTbUxPo1GDl+VhW+jxFpaAX29C TivP7aOfRZCz1sJ7dQlP4QgkFNobvZq4yS5d1nJsgMVwcWNSk4nc4t2iwHJ5XiWsaKaiX6 R1TGVIKW1q1bdwXVeFQ9lO1kaR5udDxtDGc/DUyMHHamzvLDXEzNhF0a83UJR9z+q67I5E C4xStrD1C3zCUHhMc3zeOMEsEyYH08Mc968nYoCJZaWyHX8wt44hrZf8x1O/pvgEyJkGq6 Gn5GTfUILuHq+FQwGEZnShmuLqk1z80QLVpTLOki2QHorJxZwTErqIJSJrpd/g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678236960; a=rsa-sha256; cv=none; b=mRnC99LP2eFRgpOZX2quwLowrODGYbkjLHgQwgrKc8P+120va/mzTgrmy6fa88LGFPEB0G oDb+VGL8jTXPPRi9pKh5QEcH8fs6jsD77flDnLVSSwGYZ9rc8lJXlrjOLD5MVqw7C/16QS r9PU6vk3CNbKZW/MY2x/aypPuM7eHXZ2JwYzA/LPzKOCQ4kqiu9adkpjMuCibzVI0mK+Nq RS/nSB7ZOXG2wCUykG3Yk/JbWzk91hxYbApei8lyAtGHmB0SYpeVyYBYIcyO7xaFoCcHMg oUDTvV6rP5CLwBRuauT47+wF7BYjoeBeIpNnf75Sd1oOxKYMXJ1NhVYev6Vf6w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.de header.s=2017 header.b="mucb2ex/"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.de Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZi5P-0007dP-Sm; Tue, 07 Mar 2023 19:55:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZi5M-0007d2-0M for emacs-orgmode@gnu.org; Tue, 07 Mar 2023 19:55:16 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZi5J-0007Jt-Rj for emacs-orgmode@gnu.org; Tue, 07 Mar 2023 19:55:15 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A2EA0240628 for ; Wed, 8 Mar 2023 01:55:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1678236911; bh=MA7VBIyemz0BaD23THDusm/dPonIBi0XlEgSDifNL30=; h=Date:Subject:To:Cc:From:From; b=mucb2ex/rVWl7E790YXj/QTGrqiJp8Zb1fNirnh2EIIEBCy0Qe5NIKD1m70j4a9ou SJJEcZPHDdV9iI0qidiHy0RapzV1sPkAxzVgwdXSS/5z+xVpWTrByuDLUEnQ7d0VNk H+0bLQTe0O/DgWPYPwlUrfcc1EGeuIl61vNLvFPtZbvGRRbeBCBtDpwHmehHo5NUNe W+bHard+h1+50y1y+CyL+vhe0EI3SmNn8/L2OvO4ZP4mL9qhQnraAdz0URRhRc374g HNsNw2kCo0Mqur3HGQKu8d6FOFzkaeHqSb6tacfInhxECtcpAHmoiffD8WOE6z9SpG isLJnUJkwPgIQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PWYkh2VZPz9rxL; Wed, 8 Mar 2023 01:55:08 +0100 (CET) Content-Type: multipart/alternative; boundary="------------icvI0NX3P00NOjVpJ1TXQPbG" Message-ID: <97ee254e-72d2-2bdf-e026-78bde076f1f9@posteo.de> Date: Wed, 8 Mar 2023 00:55:07 +0000 MIME-Version: 1.0 Subject: Re: org-babel guile source block bug in handling multiple values To: Bruno Barbier Cc: emacs-orgmode@gnu.org, Ihor Radchenko References: <9eab60bc-9b82-e037-d63b-3d879573ae32@posteo.de> <87v8jceihi.fsf@localhost> <7fc63848-d6d3-80e0-ae78-00967990813d@posteo.de> <64079614.170a0220.5a0d3.0a23@mx.google.com> From: Zelphir Kaltstahl Content-Language: en-US In-Reply-To: <64079614.170a0220.5a0d3.0a23@mx.google.com> Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Scanner: scn0.migadu.com X-Migadu-Queue-Id: B377116A6B X-Spam-Score: -8.38 X-Migadu-Spam-Score: -8.38 List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: J5o6lAtLBEB1 This is a multi-part message in MIME format. --------------icvI0NX3P00NOjVpJ1TXQPbG Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/7/23 20:52, Bruno Barbier wrote: > Zelphir Kaltstahl writes: > > >> If org merely wraps in a `let`, it should not notice any of the multiple values >> business, because that is something done internally in `let-values`. >> > The "let", to define the org variables, ends up putting the "import" > inside the scheme expression, like this: > > ;; -*- geiser-scheme-implementation: guile -*- > (let ((x '1) > (y '2)) > (import (except (rnrs base) error vector-map) > (only (guile) > lambda* > λ) > ;; let-values > (srfi srfi-11)) > > (let-values ([(a b) (values x y)]) > (simple-format #t "~a ~a\n" a b)) > ) > > > which raises an error when evaluated the first time (the second time, > the "import" has already imported the new "let-values" feature > (srfi-11), so, the evaluation works). You can test this manually in a > guile session. > > I guess you'll have to use sessions, and do the "import" in a separate > block first. > > Bruno Hello Bruno! Thank you for that explanation. Behaves exactly like you describe and explains things. I wonder though, whether that let wrapped code should actually cause an error, or that is a bug in Guile. Also thanks for the idea with sessions + separate import source block. I thought that should work, but apparently that also has the same error, when running for the first time: ~~~~START~~~~ #+name: scheme-time-imports #+begin_src scheme :eval query-export :noweb strip-export :session scheme-time :results output replace drawer" (import ;; let-values (srfi srfi-11)) #+end_src #+RESULTS: scheme-time-imports #+name: scheme-time #+begin_src scheme :eval query-export :noweb strip-export :session scheme-time :results output replace drawer :var x=1 :var y=2 <> (import (except (rnrs base) error vector-map) (only (guile) lambda* λ) ;; let-values (srfi srfi-11)) (let-values ([(a b) (values x y)]) (simple-format #t "~a ~a\n" a b)) #+end_src #+RESULTS: scheme-time :results: ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: a Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> :end: ~~~~~END~~~~~ Regards, Zelphir -- repositories:https://notabug.org/ZelphirKaltstahl --------------icvI0NX3P00NOjVpJ1TXQPbG Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 3/7/23 20:52, Bruno Barbier wrote:
Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:


If org merely wraps in a `let`, it should not notice any of the multiple values 
business, because that is something done internally in `let-values`.

The "let", to define the org variables, ends up putting the "import"
inside the scheme expression, like this:

      ;; -*- geiser-scheme-implementation: guile -*-
      (let ((x '1)
            (y '2))
      (import (except (rnrs base) error vector-map)
               (only (guile)
                     lambda*
                     λ)
               ;; let-values
               (srfi srfi-11))

      (let-values ([(a b) (values x y)])
         (simple-format #t "~a ~a\n" a b))
      )


which raises an error when evaluated the first time (the second time,
the "import" has already imported the new "let-values" feature
(srfi-11), so, the evaluation works). You can test this manually in a
guile session.

I guess you'll have to use sessions, and do the "import" in a separate
block first.

Bruno

Hello Bruno!

Thank you for that explanation. Behaves exactly like you describe and explains things.

I wonder though, whether that let wrapped code should actually cause an error, or that is a bug in Guile.

Also thanks for the idea with sessions + separate import source block. I thought that should work, but apparently that also has the same error, when running for the first time:

~~~~START~~~~
#+name: scheme-time-imports
#+begin_src scheme :eval query-export :noweb strip-export :session scheme-time :results output replace drawer"
(import
 ;; let-values
 (srfi srfi-11))
#+end_src

#+RESULTS: scheme-time-imports

#+name: scheme-time
#+begin_src scheme :eval query-export :noweb strip-export :session scheme-time :results output replace drawer :var x=1 :var y=2
<<scheme-time-imports>>
(import (except (rnrs base) error vector-map)
        (only (guile)
              lambda*
              λ)
        ;; let-values
        (srfi srfi-11))

(let-values ([(a b) (values x y)])
  (simple-format #t "~a ~a\n" a b))
#+end_src

#+RESULTS: scheme-time
:results:
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: a

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 
:end:
~~~~~END~~~~~

Regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl
--------------icvI0NX3P00NOjVpJ1TXQPbG--