Interactive Programming - REPL "read-eval-print loop" execution paradigm

> Code - (Programming|Computer) Language > Interactive programming

1 - About

REPL (an acronym for “read-eval-print loop”) is a execution paradigm implemented in a command line interpreter that:

  • reads what you type (i.e.
  • evaluates it,
  • and prints the result if any.

A REPL console is a synonym for a command line interpreter.

Advertising

3 - Implementation

Steps:

  • Prompt the user for some code,
  • When they’ve entered it, execute it in the same process.
while True:
    code = input(">>> ")
    exec(code)

it’s much more complex, because it has to deal with:

  • multi-line code,
  • tab completion (using readline for instance),
  • magic commands,
  • and so on.

4 - Documentation / Reference

code/interactive/repl.txt · Last modified: 2019/05/20 09:39 by gerardnico