What is a read-eval-print loop?

Definition

A programmer or agent can enter small pieces of code and inspect the results immediately. Many implementations retain variables and other session state, allowing later inputs to build on earlier work.

This supports exploration and incremental calculations. Retained state can also affect later results, so a session reset or a fresh process may be needed to reproduce an experiment clearly.

ELI5

Think of a programming notebook where you try one instruction, see the answer and decide what to try next.

For example, you could store a list of spreadsheet values, calculate their total and then reuse the same list for another calculation.

What does the loop repeat?

It repeatedly accepts input, evaluates it and displays the result before accepting more input.

Does session state always survive a restart?

No. Keeping variables during a session does not guarantee that they survive closing or resetting it.

  1. Nuno Campos in glasses and a blue top at left beside the blue and white headline "VERIFY EVERY SPREADSHEET" on black.
Definition card for read-eval-print loop: What is a read-eval-print loop?

A read-eval-print loop is an interactive programming environment that accepts input, evaluates it, displays a result and waits for more input.