emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* What is Babel's relationship with a Lisp REPL? State or stateless?
@ 2015-02-20 12:54 Lawrence Bottorff
  2015-02-20 14:13 ` John Kitchin
  2015-02-20 16:41 ` Grant Rettke
  0 siblings, 2 replies; 3+ messages in thread
From: Lawrence Bottorff @ 2015-02-20 12:54 UTC (permalink / raw)
  To: emacs-orgmode

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

If I'm creating an org file in a buffer which has source blocks for, say,
Lisp, then I can "run" these blocks of Lisp code and Babel will fill in the
"answer" just below in my buffer. Good. As advertised. But what is really
happening to this code? Does Babel invoke a Lisp REPL once, do the code,
print out the results my buffer and go away? Or is this invoked REPL
somehow persistent, able to remember what has happened before?

With regular Lisp and SLIME, you have a buffer where you write your code
next to a running REPL that handles the code when you ask it to. It keeps
"state" and your program grows. But this arrangement is not really literate
programming. Maybe good comments are possible, but it's not orgmode
literate programming.

But then again, if Babel doesn't support REPL "state," then what am I
gaining? Please enlighten me. . . .


LB

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What is Babel's relationship with a Lisp REPL? State or stateless?
  2015-02-20 12:54 What is Babel's relationship with a Lisp REPL? State or stateless? Lawrence Bottorff
@ 2015-02-20 14:13 ` John Kitchin
  2015-02-20 16:41 ` Grant Rettke
  1 sibling, 0 replies; 3+ messages in thread
From: John Kitchin @ 2015-02-20 14:13 UTC (permalink / raw)
  To: Lawrence Bottorff; +Cc: emacs-orgmode

I think it saves state, and remembers what has been done, at least as
long as emacs is open. If you close emacs, it will forget everything,
and you would have to rerun each block. You could tangle (or selectively
tangle) the blocks out, to get an emacs-lisp file, which might then be a
library you would load or run.

Here is a little example I tried it out on. If you run these blocks in
order you should see the state is saved as if it was a continuous
session.

What do you gain? That is for you to say. you can write emacs lisp and
execute one sexp at a time in an emacs-lisp buffer, and write comments
almost the same way. I like/prefer editing in org-mode for text, and
simple sexps. For really big libraries, I like using org-mode to
organize it into an outline. sometimes I prefer emacs-lisp mode for
editing emacs-lisp code. these are C-c ' apart in org-mode, or if you
have tried the lentic package, you can have separate views of the same
file in different modes.

* elisp

#+BEGIN_SRC emacs-lisp
(setq *some-var* "test")
#+END_SRC
#+RESULTS:
: test


Now some commentary

#+BEGIN_SRC emacs-lisp
*some-var*
#+END_SRC

#+RESULTS:
: test

define something
#+BEGIN_SRC emacs-lisp
(defun test-func ()
  *some-var*)
#+END_SRC

#+RESULTS:
: test-func

#+BEGIN_SRC emacs-lisp
(test-func)
#+END_SRC

#+RESULTS:
: test


Lawrence Bottorff writes:

> If I'm creating an org file in a buffer which has source blocks for, say,
> Lisp, then I can "run" these blocks of Lisp code and Babel will fill in the
> "answer" just below in my buffer. Good. As advertised. But what is really
> happening to this code? Does Babel invoke a Lisp REPL once, do the code,
> print out the results my buffer and go away? Or is this invoked REPL
> somehow persistent, able to remember what has happened before?
>
> With regular Lisp and SLIME, you have a buffer where you write your code
> next to a running REPL that handles the code when you ask it to. It keeps
> "state" and your program grows. But this arrangement is not really literate
> programming. Maybe good comments are possible, but it's not orgmode
> literate programming.
>
> But then again, if Babel doesn't support REPL "state," then what am I
> gaining? Please enlighten me. . . .
>
>
> LB

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: What is Babel's relationship with a Lisp REPL? State or stateless?
  2015-02-20 12:54 What is Babel's relationship with a Lisp REPL? State or stateless? Lawrence Bottorff
  2015-02-20 14:13 ` John Kitchin
@ 2015-02-20 16:41 ` Grant Rettke
  1 sibling, 0 replies; 3+ messages in thread
From: Grant Rettke @ 2015-02-20 16:41 UTC (permalink / raw)
  To: Lawrence Bottorff; +Cc: emacs-orgmode@gnu.org

Does this answer your question?

http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lisp.html#sec-3-2

I usually set up Scheme and R to keep a single buffer around with
Racket or R running in them. I do work in there outside of org just
like I do inside of org; figure stuff out and rely on the single
memory state. That is the typical development workflow.

On Fri, Feb 20, 2015 at 6:54 AM, Lawrence Bottorff <borgauf@gmail.com> wrote:
> If I'm creating an org file in a buffer which has source blocks for, say,
> Lisp, then I can "run" these blocks of Lisp code and Babel will fill in the
> "answer" just below in my buffer. Good. As advertised. But what is really
> happening to this code? Does Babel invoke a Lisp REPL once, do the code,
> print out the results my buffer and go away? Or is this invoked REPL somehow
> persistent, able to remember what has happened before?
>
> With regular Lisp and SLIME, you have a buffer where you write your code
> next to a running REPL that handles the code when you ask it to. It keeps
> "state" and your program grows. But this arrangement is not really literate
> programming. Maybe good comments are possible, but it's not orgmode literate
> programming.
>
> But then again, if Babel doesn't support REPL "state," then what am I
> gaining? Please enlighten me. . . .
>
>
> LB



-- 
Grant Rettke
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-20 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-20 12:54 What is Babel's relationship with a Lisp REPL? State or stateless? Lawrence Bottorff
2015-02-20 14:13 ` John Kitchin
2015-02-20 16:41 ` Grant Rettke

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