emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: appearance of list as results from evaluating code blocks


From: Tim Cross
Subject: Re: appearance of list as results from evaluating code blocks
Date: Sat, 26 Jun 2021 17:48:00 +1000
User-agent: mu4e 1.5.13; emacs 28.0.50

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 via email to

[Prev in Thread] Current Thread [Next in Thread]