From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-babel guile source block bug in handling multiple values
Date: Tue, 7 Mar 2023 15:18:26 +0000 [thread overview]
Message-ID: <7fc63848-d6d3-80e0-ae78-00967990813d@posteo.de> (raw)
In-Reply-To: <87v8jceihi.fsf@localhost>
On 3/7/23 15:36, Ihor Radchenko wrote:
> Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:
>
>> * 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:
> I am not familiar with scheme, but AFAIK all ob-scheme does is wrapping
> the code block into (let (...) ,@body) See `org-babel-expand-body:scheme'.
>
> May the problem be with your let-values form?
The problem seems to be associated with returning multiple values, which
`let-values` is designed to capture. The expression `(values ...)` returns 2
values and the `(let ([(a b) <multi-value-expression>]) <body>)` will capture
those 2 values, binding them to `a` and `b`. The `(let-values ...)` then creates
a value (or in other scenarios any number of values) in its `<body>` part as a
result of the whole `let-values` expression. In my case the body performs a
side-effect of printing something out, which is required to get something as an
output of the source block.
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`.
I can run the code in geiser manually without error, but when I run it as a
source block, I get the error as seen in the example org document of my original
e-mail.
--
repositories: https://notabug.org/ZelphirKaltstahl
next prev parent reply other threads:[~2023-03-07 15:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 11:27 org-babel guile source block bug in handling multiple values Zelphir Kaltstahl
2023-03-07 14:36 ` Ihor Radchenko
2023-03-07 15:18 ` Zelphir Kaltstahl [this message]
2023-03-07 19:52 ` Bruno Barbier
2023-03-08 0:55 ` Zelphir Kaltstahl
2023-03-08 19:38 ` Bruno Barbier
2023-03-09 0:44 ` Zelphir Kaltstahl
2023-03-09 13:04 ` [BUG] Inconsistent global/local :var assignments in ob-* for lisps and non-lisps (was: org-babel guile source block bug in handling multiple values) Ihor Radchenko
2023-03-10 10:39 ` Zelphir Kaltstahl
2023-03-11 9:58 ` Ihor Radchenko
2023-03-11 18:30 ` Zelphir Kaltstahl
2023-03-12 11:33 ` Ihor Radchenko
2023-03-19 13:50 ` [PATCH] lisp/ob-scheme.el Zelphir Kaltstahl
2023-03-22 10:43 ` Ihor Radchenko
2023-03-25 14:34 ` Zelphir Kaltstahl
2023-03-26 9:32 ` Ihor Radchenko
2023-04-25 12:28 ` Ihor Radchenko
2023-04-29 11:08 ` Zelphir Kaltstahl
2023-03-09 13:10 ` org-babel guile source block bug in handling multiple values Ihor Radchenko
2023-03-10 10:42 ` Zelphir Kaltstahl
2023-03-11 10:18 ` Ihor Radchenko
2023-06-02 13:11 ` Ihor Radchenko
2023-03-09 13:11 ` Ihor Radchenko
2023-03-09 14:21 ` Daniel Kraus
2023-03-10 11:57 ` Ihor Radchenko
2023-03-10 10:45 ` Zelphir Kaltstahl
2023-03-08 1:13 ` Zelphir Kaltstahl
2023-03-08 8:55 ` Ihor Radchenko
2023-03-07 15:44 ` Max Nikulin
2023-03-07 21:41 ` Rudolf Adamkovič
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7fc63848-d6d3-80e0-ae78-00967990813d@posteo.de \
--to=zelphirkaltstahl@posteo.de \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.