emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: appearance of list as results from evaluating code blocks
Date: Sat, 26 Jun 2021 17:48:00 +1000	[thread overview]
Message-ID: <87h7hl2gw3.fsf@gmail.com> (raw)
In-Reply-To: <CAJ51ETqOMkczQ1oWvUBvW4DYnvhXLMhcksdogSkhi_-JC3qWqw@mail.gmail.com>


John Kitchin <jkitchin@andrew.cmu.edu> writes:

> I think something is fishy in ob-clojure.
>
> When I look at how it runs, it is not obvious it is returning anything. Instead it is wrapping the body like this
>
> "(clojure.pprint/pprint (do (list 1 2 (+ 1 2))))"
>
> which I assume is going to stdout maybe? 
>
> With Cider I eventually got to this intermediate result, which looks like maybe there is a terminating nil getting read from the repl that is eventually
> chomped to "".
>
> Result: (dict "status" ("done" "state") "id" "12" "out" "(1 2 3)\nnil\n" "session" "c72a3a11-8982-4ead-a0bf-cb92a24a966c" "ns" "user" "value" "nil"
> "changed-namespaces" (dict) "repl-type" "clj")
>

Yes, I think your probably correct.

If the form is wrapped in (clojure.pprint/pprint ....), then the 'code'
result from evaluation would indeed be nil as the return value for
pprint is nil.

The ob-clojure module is IMO a little 'odd' because it uses cider, so
there is another layer of indirection you don't see with other ob-*
which just run the code inside a language shell. I also find this
distinction between 'code' and 'value' a bit confusing at times. I can
see why something is needed (for example, when running shell scripts and
sometimes you want the 'output' and sometimes you want the exit code
etc. However, the distinction is less clear in some languages, like
clojure, where there is no real distinction i.e. how does code differ
from value as a result? What does 'code' really mean in this context?.

I think the ob-clojure library probably needs a bit of work. Since it
was originally written, clojure has moved on a bit and it would probably
make sense to look at possibly basing it on clj-tools rather than cider.
When I was trying to use it, I constantly ran into problems because
cider was evolving too rapidly and things kept breaking. I actually had
better success using the 'inf-clojure' interface, but that had issues
too (for example, with the :session switch).

Someone did send in a patch some months back which had a first go at
implementing support for clj-tools. I was too busy to review it at the
time., I later went to have a look at it and a message was sent to the
patch author for a copy of the most recent version of the patch, but
there was no response. 
-- 
Tim Cross


  reply	other threads:[~2021-06-26  8:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 14:23 appearance of list as results from evaluating code blocks Johannes Brauer
2021-06-24 16:28 ` John Kitchin
2021-06-24 17:47   ` Johannes Brauer
2021-06-25 16:16     ` John Kitchin
2021-06-26  7:48       ` Tim Cross [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-06-23 19:27 Johannes Brauer
2021-06-23 19:43 ` Juan Manuel Macías
2021-06-23 20:03   ` Johannes Brauer
2021-06-23 21:13     ` Rodrigo Morales
2021-06-23 21:14     ` Rodrigo Morales
2021-06-23 21:24       ` George Mauer
2021-06-24 10:46       ` Johannes Brauer
2021-06-24 11:28         ` Eric S Fraga

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7hl2gw3.fsf@gmail.com \
    --to=theophilusx@gmail.com \
    --cc=emacs-orgmode@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).