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 uEW6EMQfB2RJ9gAASxT56A (envelope-from ) for ; Tue, 07 Mar 2023 12:28:04 +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 MCy7EMQfB2TYNQAA9RJhRA (envelope-from ) for ; Tue, 07 Mar 2023 12:28:04 +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 F366230AC8 for ; Tue, 7 Mar 2023 12:28:02 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZVTN-0006GX-8X; Tue, 07 Mar 2023 06:27:13 -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 1pZVTL-0006GA-Jl for emacs-orgmode@gnu.org; Tue, 07 Mar 2023 06:27:11 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZVTI-0005SD-G4 for emacs-orgmode@gnu.org; Tue, 07 Mar 2023 06:27:11 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 3CB52240729 for ; Tue, 7 Mar 2023 12:27:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1678188424; bh=5gD6innqym0jsZjAKR2fLBrZAZl5lyGgUCt3mQoHYck=; h=Date:To:From:Subject:From; b=ibk/UyPf42195d951/VN5znvsHJBzOTkfoWmy+FqN9CA191NctNRb+63DSpRMFNSZ KsC61z7IjG0YN3Cgd1+0094R0qY27X2HiJritd6jRN46s6oeHCjN4pS+wkF+fBwDCL rHtgmh7py9rStmUUeUi6PAGk93oh9bLhMcuh/+jlch56ioyXWFkewLLowsCK0wo9+F sG5GJ64AXufhTjDorlZxLldttfSEHfCfg1vCW8mUhqQPR/C0ZnH4/1M3YpDB/OHWUP 7Pc93Ig/GReO43awO0oOySCQdmT827m41n0bzI+IQTv+BHibqSm85ZA5JWd0zb3CFp K0NcvS3MCPeCg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PWCpH4sTZz6trW for ; Tue, 7 Mar 2023 12:27:02 +0100 (CET) Content-Type: multipart/alternative; boundary="------------LSG8yeM00h3sBlm5hNa1OrW8" Message-ID: <9eab60bc-9b82-e037-d63b-3d879573ae32@posteo.de> Date: Tue, 7 Mar 2023 11:27:02 +0000 MIME-Version: 1.0 To: emacs-orgmode@gnu.org From: Zelphir Kaltstahl Content-Language: en-US Subject: org-babel guile source block bug in handling multiple values Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.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: 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678188483; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=JfBN2VmEuW839f+XKMioTrMKiqHO9RGsXmDvqFCVf00=; b=V3TK1XKtQJQ3U9Wwhfe54Inxg/X1RI0AM5tixNNvh6w9gELZ9Fs9+jduM4u2VLxNI0P666 om7P5uRiyLsxgxdC7W7CyaOIdLBJS5j1mXl1Rb21vJX2TSIfSntQTTFz0eOd6ON0yh88wR 01xjFNnu/tHs5HJ13/BQYkLf1vTDj4sgABEJoq2TL/Z7ThKHHUHysEyFnxzXLrFK6jEtRl vaoVaMsOKwffYdA7KrjzMUGKf38BTPYmoOmC0NlLj/eVKkAdR66KGvBGr/PNEDl46KO0eS Z0J7BoTLjSwiNpzOq65NSdVVJ0+eykrOzg/DalqYQltVK3bx/fmtXXMmSMbASw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.de header.s=2017 header.b="ibk/UyPf"; 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-Seal: i=1; s=key1; d=yhetil.org; t=1678188483; a=rsa-sha256; cv=none; b=hVF1G8eUGSqq+Kl2sbuop/o32TBso0IhiXWhVCT9CCNpGggKo9I8gtmLXAtfrbjctWoB87 r5tgiMq3q7KnueaWj4Go0IIoTP05zDblzoYoFt+2efE6/WEI6Oa49fHP0oAXljS00gntgB Uje2E+IZStQTsKIFayahrOk1Mn6P4c13d0+JscFPpAUzhSUf4klqU5O1MPQPfeCkyN97Vh 1JsZtbBhRG6BDpeUKcWG8zg11DRCflZJwO6/3IDA6eUgRFXmh245tANLXVVltieN5dIHY7 9ifyqw0nf9gYDAf2eL2ugyNrjoCP2ebi8y/t1sS+Xxjcwkpag4pciJMWcm7V3w== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.de header.s=2017 header.b="ibk/UyPf"; 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 X-Migadu-Spam-Score: -6.28 X-Spam-Score: -6.28 X-Migadu-Queue-Id: F366230AC8 X-Migadu-Scanner: scn1.migadu.com X-TUID: +m375sBc5R4y This is a multi-part message in MIME format. --------------LSG8yeM00h3sBlm5hNa1OrW8 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Org users! I think I found a bug in how org-babel works with at least GNU Guile source blocks. I could not reproduce this for example with a racket source block, because somehow there is no ob-racket and I think I would need that. I could try other Schemes like maybe Chicken, if there is ob-chicken or so available. The issue happens on 2 separate machines. I am not sure on which repository I should open an issue for this specific bug, or if perhaps this mailing list is exactly the right place. Feel free to point me elsewhere : ) What follows are my notes trying to narrow it down, as an org document. ~~~~START~~~~ * General There seems to be an issue with returning multiple values, which result from =:var= variables / whose computation involves =:var= variables. Handling multiple trivial values like ~1~ or ~2~ seems to work fine. * Primitive multiple values work #+begin_src scheme :eval query-export :results output replace drawer (import (except (rnrs base) error vector-map) (only (guile) lambda* λ) ;; let-values (srfi srfi-11)) (let-values ([(a b) (values 1 2)]) (simple-format #t "~a ~a\n" a b)) #+end_src #+RESULTS: :results: 1 2 :end: * Multiple values involving =:var= variables #+begin_src scheme :eval query-export :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: :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: ** Is it about =:var= variables in values? #+begin_src scheme :eval query-export :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)) (define plus-x (λ (num) (+ num x))) (define plus-y (λ (num) (+ num y))) (let-values ([(a b) (values (plus-x 1) (plus-y 2))]) (simple-format #t "~a ~a\n" a b)) #+end_src #+RESULTS: :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: ** Defining and using defined variables What about defining and using the defined variables instead of the =:var= variables directly? #+begin_src scheme :eval query-export :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)) (define inner-x x) (define inner-y y) (define plus-x (λ (num) (+ num inner-x))) (define plus-y (λ (num) (+ num inner-y))) (let-values ([(a b) (values (plus-x 1) (plus-y 2))]) (simple-format #t "~a ~a\n" a b)) #+end_src #+RESULTS: :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: It seems not to work whenever the ~(values ...)~ is not only trivial values, but variables or function calls. * With named :session Works after running it once with error: #+begin_src scheme :session mysession :eval query-export :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: :results: 1 2 :end: Seems like it gets stored in the session and then can be used in the second run of the source block. ~~~~~END~~~~~ Versions of things: + guile @ =3.0.9= + org-mode @ =9.6.1= + org-babel @ (integrated into org-mode) + geiser-guile @ =0.28.1= Workarounds: Of course, I could return lists instead of multiple values and then pattern match on them or use separate functions for getting the values separately. Downside: Might be more computation and requires changing code just, because for using it in org source blocks. -- repositories:https://notabug.org/ZelphirKaltstahl --------------LSG8yeM00h3sBlm5hNa1OrW8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hello Org users!

I think I found a bug in how org-babel works with at least GNU Guile source blocks. I could not reproduce this for example with a racket source block, because somehow there is no ob-racket and I think I would need that. I could try other Schemes like maybe Chicken, if there is ob-chicken or so available. The issue happens on 2 separate machines.

I am not sure on which repository I should open an issue for this specific bug, or if perhaps this mailing list is exactly the right place. Feel free to point me elsewhere : )

What follows are my notes trying to narrow it down, as an org document.

~~~~START~~~~
* General

There seems to be an issue with returning multiple values, which result from =:var= variables / whose computation involves =:var= variables. Handling multiple trivial values like ~1~ or ~2~ seems to work fine.

* Primitive multiple values work

#+begin_src scheme :eval query-export :results output replace drawer
(import (except (rnrs base) error vector-map)
        (only (guile)
              lambda*
              λ)
        ;; let-values
        (srfi srfi-11))

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

#+RESULTS:
:results:
1 2
:end:

* Multiple values involving =:var= variables

#+begin_src scheme :eval query-export :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:
: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:

** Is it about =:var= variables in values?

#+begin_src scheme :eval query-export :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))

(define plus-x
  (λ (num)
    (+ num x)))

(define plus-y
  (λ (num)
    (+ num y)))

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

#+RESULTS:
: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:

** Defining and using defined variables

What about defining and using the defined variables instead of the =:var= variables directly?

#+begin_src scheme :eval query-export :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))

(define inner-x x)
(define inner-y y)

(define plus-x
  (λ (num)
    (+ num inner-x)))

(define plus-y
  (λ (num)
    (+ num inner-y)))

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

#+RESULTS:
: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:

It seems not to work whenever the ~(values ...)~ is not only trivial values, but variables or function calls.

* With named :session

Works after running it once with error:

#+begin_src scheme :session mysession :eval query-export :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:
:results:
1 2
:end:

Seems like it gets stored in the session and then can be used in the second run of the source block.
~~~~~END~~~~~

Versions of things:

+ guile @ =3.0.9=
+ org-mode @ =9.6.1=
+ org-babel @ (integrated into org-mode)
+ geiser-guile @ =0.28.1=

Workarounds:

Of course, I could return lists instead of multiple values and then pattern match on them or use separate functions for getting the values separately. Downside: Might be more computation and requires changing code just, because for using it in org source blocks.

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