News for hackers. Stuff that matters.
Re:Programming at the REPL (2018) by Jtsummers on Friday July 10, 2020 @01:10PM (#23793720)
And if you have language support in org, use an org file.

  #+BEGIN_SRC lisp
    (+ 1 2)
  #+END_SRC

  #+RESULTS:
  : 3
(type C-c C-c inside the source block)

If you use noweb it'll also include referenced blocks in the evaluated unit:

  #+NAME: foo
  #+BEGIN_SRC lisp
    (defun foo (n) (+ 1 n))
  #+END_SRC

  #+BEGIN_SRC lisp :noweb yes
    <<foo>>
    (foo 2)
  #+END_SRC

  #+RESULTS:
  : 3
This lets you have many versions of code in one file (if that's a sensible thing for you, very useful when exploring a new library or concept though), and in the end you can aggregate it all into one source file for sharing with others:

  #+BEGIN_SRC lisp :tangle foo.lisp
    <<foo>>
    <<bar>>
  #+END_SRC
(type C-c C-v C-t to create the file)

I've mainly used this (for interactive development) with Common Lisp, but it should work for most other languages that offer similar interactivity.

There are no comments on this comment yet.