Questions tagged [read-eval-print-loop]

A Read-Eval-Print Loop (REPL) is the most common model for an interactive interpreter - it Reads input, Evaluates it, Prints it, and Loops back to the beginning.

A Read-Eval-Print Loop (REPL) is an interactive interpreter to a programming language. It originated with LISP systems, but many other languages (Python, Ruby, Haskell, Tcl, Java etc.) use REPL's to manage interactive sessions. They allow for simple experimentation with a language by bypassing the compile stage of the "code -> compile -> execute" cycle.

There are 4 components to a REPL (named in LISP notation):

  • A read function, which reads input from the keyboard
  • An eval function, which evaluates code passed to it
  • A print function, which formats and displays results
  • A loop function, which runs the three previous commands until termination
1493 questions
462
votes
20 answers

How to save a Python interactive session?

I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to…
unmounted
  • 33,530
  • 16
  • 61
  • 61
309
votes
24 answers

How can I start an interactive console for Perl?

How can I start an interactive console for Perl, similar to the irb command for Ruby or python for Python?
ibz
  • 44,461
  • 24
  • 70
  • 86
274
votes
13 answers

Does Go provide REPL?

The interactive environment is VERY helpful for a programmer. However, it seems Go does not provide it. Is my understanding correct?
z_axis
  • 8,272
  • 7
  • 41
  • 61
260
votes
8 answers

How do I load a file into the python console?

I have some lines of python code that I'm continuously copying/pasting into the python console. Is there a load command or something I can run? e.g. load file.py
sybind
  • 3,418
  • 5
  • 25
  • 25
191
votes
8 answers

How to reload a clojure file in REPL

What is the preferred way of reloading functions defined in a Clojure file without having to restart the REPL. Right now, in order to use the updated file I have to: edit src/foo/bar.clj close the REPL open the REPL (load-file…
pkaleta
  • 2,129
  • 2
  • 13
  • 9
187
votes
12 answers

How do I load my script into the node.js REPL?

I have a script foo.js that contains some functions I want to play with in the REPL. Is there a way to have node execute my script and then jump into a REPL with all the declared globals, like I can with python -i foo.py or ghci foo.hs?
hugomg
  • 68,213
  • 24
  • 160
  • 246
129
votes
2 answers

What command opens Ruby's REPL?

What command opens Ruby's REPL? In Python, you simply open python without any arguments.
Jian
  • 10,320
  • 7
  • 38
  • 43
114
votes
12 answers

How to disable "Save workspace image?" prompt in R?

When I exit the interactive R shell, it displays an annoying prompt every time: > > Save workspace image? [y/n/c]: n I'm always answering "no" to it, because if I wished to save my work, I'd do that before trying to exit. How to get rid of the…
ulidtko
  • 14,740
  • 10
  • 56
  • 88
111
votes
13 answers

Is there an interpreter for C?

I was wondering if there is something like an interpreter for C. That is, in a Linux terminal I can type in "python" and then code in that interpreter. (I'm not sure interpreter the right word). This is really helpful for testing different things…
devin
  • 6,407
  • 14
  • 48
  • 53
110
votes
14 answers

How can I use swift in Terminal?

I read What's new in Xcode 6. The article introduces some new feature about Xcode 6, and it says: Command Line Xcode’s debugger includes an interactive version of the Swift language, known as the REPL (Read-Eval-Print-Loop). Use Swift syntax to…
riven
  • 1,476
  • 2
  • 12
  • 15
93
votes
29 answers

Is there something like python's interactive REPL mode, but for Java?

Is there something like python's interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing?
Yoni Roit
  • 28,280
  • 7
  • 36
  • 32
77
votes
4 answers

How to use third party libraries with Scala REPL?

I've downloaded Algebird and I want to try out few things in the Scala interpreter using this library. How do I achieve this?
Harshal Kshatriya
  • 5,630
  • 11
  • 44
  • 60
75
votes
8 answers

Have you used any of the C++ interpreters (not compilers)?

I am curious if anyone have used UnderC, Cint, Cling, Ch, or any other C++ interpreter and could share their experience.
Allan Wind
  • 23,068
  • 5
  • 28
  • 38
70
votes
1 answer

What is the best way to test and interact with inner functions defined inside a toplevel function?

When I program in Javascript, I find it extremely convenient to be able to use the debugger to halt program execution at any point and to be able to runs commands and inspect variables from there. Now, back in Haskell, is there a way to run…
hugomg
  • 68,213
  • 24
  • 160
  • 246
70
votes
3 answers

How to get the last exception object after an error is raised at a Python prompt?

When debugging Python code at the interactive prompt (REPL), often I'll write some code which raises an exception, but I haven't wrapped it in a try/except, so once the error is raised, I've forever lost the exception object. Often the traceback and…
Ben Hoyt
  • 10,694
  • 5
  • 60
  • 84
1
2 3
99 100