Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language history: origin of variable 'it' in read-eval-print loop?

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?

like image 617
Norman Ramsey Avatar asked Jul 24 '10 20:07

Norman Ramsey


People also ask

What is read eval print loop in Python?

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.

What command initiates the read evaluate print loop REPL )?

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.

Why is REPL useful?

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.

Which programming language is most commonly interacted with via a REPL?

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.


1 Answers

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.

like image 183
jtbandes Avatar answered Oct 11 '22 14:10

jtbandes