Some interactive systems, including Standard ML of New Jersey and GHC, offer an interactive toplevel loop where you can type expressions and see results. A nice little convenience is that the result of the most recent expression is bound to the variable it
. Here's an example from GHCi:
Prelude> 3 + 5
8
Prelude> it
8
Prelude> 2 * it
16
Prelude> it + 1
17
I'm trying to trace the origin of this convention. Can anyone provide examples of other interactive systems that have used similar conventions? And date them if possible?
A Read-Eval-Print Loop, or REPL, is a computer environment where user inputs are read and evaluated, and then the results are returned to the user. REPLs provide an interactive environment to explore tools available in specific environments or programming languages.
REPL. REPL stands for read-eval-print loop. That is to say that a REPL will take input (read), run those commands/code (evaluate), and print out the results, all in a loop.
REPL stands for read-evaluate-print-loop and this is basically all there is to it. Your application runtime is in a specific state and the REPL helps you to interact with it. The REPL will read and evaluate the commands and print the result and then go back to the start to read your next input.
The most straightforward way to start talking to Python is in an interactive Read-Eval-Print Loop (REPL) environment. That simply means starting up the interpreter and typing commands to it directly. The interpreter: Reads the command you enter.
Ruby provides the same convenience variable as _
:
>> 3 + 5
=> 8
>> _
=> 8
>> 2 * _
=> 16
>> _ + 1
=> 17
Interestingly, the global variable $_
is also available: it's the last input read from gets
or readline
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With