.mfile open in a text editor, and a Matlab (or Octave) terminal (aka REPL?) open. Then I edit, save, load in terminal to run, see result, and repeat. Maybe I'll use the built-in editor in Matlab or QtOctave, or maybe I'll use Emacs. It doesn't matter much.
Then I come to this Clojure thing. Spent all my time setting up SLIME in Emacs so I have a REPL right there inside Emacs, along with my file of code (the
.cljfile). But actually all I really care for is setting up my edit, save, load in terminal/REPL to run, see result, and repeat loop!
Turns out it's simple, the key being using
Say I have the following in a file located at
(def x 1)
(Yes, the code is completely useless.)
And now to run it in the REPL. Go to the REPL and enter:
In Emacs, I was able to type in
~and tab to auto-complete the path to my home directory.
The great thing is that I can inspect what went on in the
main.cljfile after executing it with
load-file. For example, in the REPL, enter
mymain/xto reveal its obvious value 1.
This would be great for data analysis work. Write up a program that's saved in a file. Load and run the program from the saved file. Interact with the result in the REPL. Fun!
This is actually my personal workflow for all kinds of programming-like related tasks. It's a bit primitive, but it works for me, and it adapts well to how I like to work (plenty of constant feedback).
As an example, suppose I'm editing an HTML file as I code up a web page. I'll have the HTML file open in one text editor window, and the same file open in a web browser window. Edit, save, reload in browser, see result, and repeat. Maybe I'll use Emacs, maybe I'll use Notepad.exe of TextEdit.app. I'll vary the browser. Maybe I set up an automation to save me the manual work of looping through that work flow, but the basic idea stays the same.
Same when I used to do some programming in Java or C. Editor and terminal. Edit, save, compile, see result, and repeat.
Same when I'm writing in LaTeX. Emacs, terminal to run pdflatex, and the PDF viewer.