emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Johannes Brauer <brauer@nordakademie.de>
Cc: "gmauer@gmail.com" <gmauer@gmail.com>, orgmode <emacs-orgmode@gnu.org>
Subject: Re: appearance of list as results from evaluating code blocks
Date: Fri, 25 Jun 2021 12:16:20 -0400	[thread overview]
Message-ID: <CAJ51ETqOMkczQ1oWvUBvW4DYnvhXLMhcksdogSkhi_-JC3qWqw@mail.gmail.com> (raw)
In-Reply-To: <5C74CBCB-3AFF-4AF3-A4AC-69BF05192972@nordakademie.de>

[-- Attachment #1: Type: text/plain, Size: 2864 bytes --]

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

That is my best guess for why you don't see the output. This happens in the
function ob-clojure-eval-with-cider.
John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Thu, Jun 24, 2021 at 1:47 PM Johannes Brauer <brauer@nordakademie.de>
wrote:

> Hi John!
>
> There is no „return“ in Lisp languages. The return value of (list 1 2 3)
> is (1 2 3). Clojure is a Lisp language similar to Elisp. So
>
> #+begin_src clojure :results code
>> (list 1 2 (+ 1 2))
>>   #+end_src
>>
>
> should work for Clojure as it does für Elisp.
>
> Johannes
>
>
> Am 24.06.2021 um 18:28 schrieb John Kitchin <jkitchin@andrew.cmu.edu>:
>
> That probably means the clojure block is returning nil as the value. I
> don't know what it means to return something in clojure, but here is what
> you have to do with Python, for example.
>
> #+BEGIN_SRC python :results value code
> [1, 2, 3]
> #+END_SRC
>
> #+RESULTS:
> #+begin_src python
> None
> #+end_src
>
> You have to explicitly return a value to see it.
>
> #+BEGIN_SRC python :results value code
> return [1, 2, 3]
> #+END_SRC
>
> #+RESULTS:
> #+begin_src python
> [1, 2, 3]
> #+end_src
>
>
> John
>
> -----------------------------------
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Thu, Jun 24, 2021 at 10:31 AM Johannes Brauer <brauer@nordakademie.de>
> wrote:
>
>> What about :results code
>> The default is a elisp code block so you get syntax coloring
>>
>>
>> That works fore lisp:
>>
>>   #+begin_src elisp :results code
>> (list 1 2 (+ 1 2))
>>   #+end_src
>>
>>   #+RESULTS:
>>   #+begin_src elisp
>>   (1 2 3)
>>   #+end_src
>>
>> But with Clojure I get
>>
>>   #+begin_src clojure :results code
>> (list 1 2 (+ 1 2))
>>   #+end_src
>>
>>   #+RESULTS:
>>   #+begin_src clojure
>>   nil
>>   #+end_src
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 6560 bytes --]

  reply	other threads:[~2021-06-25 16:17 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 [this message]
2021-06-26  7:48       ` Tim Cross
  -- 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=CAJ51ETqOMkczQ1oWvUBvW4DYnvhXLMhcksdogSkhi_-JC3qWqw@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --cc=brauer@nordakademie.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=gmauer@gmail.com \
    /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).