emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Martin Alsinet <martin@alsinet.com.ar>
To: garjola@garjola.net
Cc: emacs-orgmode@gnu.org
Subject: Re: C++ sessions for Babel with cling interpreter
Date: Sun, 05 Nov 2017 23:42:12 +0000	[thread overview]
Message-ID: <CABUJmkBeDSa0dPGffs5vSGAvcvMZhZhEKD5xNZi-gwi-jGTS7w@mail.gmail.com> (raw)
In-Reply-To: <87po8wir9s.fsf@pc-117-162.i-did-not-set--mail-host-address--so-tickle-me>

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

Hello Garjola:

I have not used C++ source blocks, but I use them frequently with
Javascript and Python, and I don't use sessions.
The thing is, for literate programming, we want to include the code from
one source block in others, and it would seem that sessions are the
solution.
However, I find that for me it is better to use tangle to export the code
to source files and then include the tangled files from the other source
blocks.

Example:

#+BEGIN_SRC js :tangle src/hello.js
function hello(text) {
    console.log("hello " + text);
}
module.exports = hello;
#+END_SRC

First I have to run *org-babel-tangle* to export all source blocks to
files, and then I can include them in other blocks.

#+BEGIN_SRC js
const hello = require("./src/hello.js");
hello("Martin");
#+END_SRC

From what I remember, it is possible to do the same in C++, including the
source files you need from the filesystem.
In my opinion, this approach is better than sessions, because the problem
with sessions is that you have to make sure the blocks are executed
secuentially in the right order to build the "state" that allows you to run
your current block. This way each block is independent of all others, worst
case you have to run org-babel-tangle to create the required files.

Regards,


Martín


On Sun, Nov 5, 2017 at 12:13 PM <garjola@garjola.net> wrote:

> Hi all,
>
> I use C++ source code blocks in babel frequently and I am very happy with
> the results. As C++ is a compiled language, ob-C.el does not support
> sessions.
>
> Unfortunately, this breaks a little my litterate programming workflow,
> since I don't know how to use small code snippets without sessions.
>
> I have recently discovered cling [1], [2] a C++ interpreter which comes
> with de Root package [3]. I have also found a cling inferior mode [4] to
> interact with the interpreter in a comint buffer.
>
> I was wondering if it would be difficult to update ob-C.el to use cling
> for session support. My elisp knowledge is too poor to understand what is
> involved in doing such a thing, but I would be interested in trying or
> helping somebody do it. Unfortunately, I have the impression that the
> developers of ob-C.el are not around this list anymore?
>
> I would very much appreciate suggestions on how to proceed.
>
> Thank you.
>
> Garjola.
>
> Footnotes:
> [1]  https://root.cern.ch/cling
> [2]  https://www.youtube.com/watch?v=Lbi7MLS03Yc
> [3]  https://root.cern.ch/
> [4]  https://github.com/brianqq/inferior-cling
>
> --
> Dr. Dindi
> Dad, Philosopher, Hacker
>
>

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

      reply	other threads:[~2017-11-05 23:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-05 17:12 C++ sessions for Babel with cling interpreter garjola
2017-11-05 23:42 ` Martin Alsinet [this message]

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=CABUJmkBeDSa0dPGffs5vSGAvcvMZhZhEKD5xNZi-gwi-jGTS7w@mail.gmail.com \
    --to=martin@alsinet.com.ar \
    --cc=emacs-orgmode@gnu.org \
    --cc=garjola@garjola.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 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).