REPL
The REPL (Read-Eval-Print Loop) is an interactive mode where you can type Pebble code one line at a time and see results immediately. It's like having a conversation with the language — you type something, it responds, and you can keep going.
Starting the REPL
Run pebble with no arguments:
The pebble> prompt means the REPL is waiting for your input.
Trying Things Out
Type any Pebble code and press Enter:
Variables Stick Around
When you declare a variable, it stays available for future inputs:
You can change variables too:
Functions Persist Too
Define a function on one line, call it on the next:
Multi-Line Input
When your code has a { that hasn't been closed yet, the REPL knows you're
not done and shows ... to ask for more:
The REPL counts opening { and closing } braces. It keeps reading lines
until they balance.
Errors Don't Crash
If you make a mistake, the REPL shows an error message and lets you keep going — it doesn't quit:
Your previous variables and functions are still there after an error.
Exiting
Press Ctrl-D (or Ctrl-Z on Windows) to exit the REPL.
How It Works
Behind the scenes, the REPL maintains persistent state across inputs:
- Variables — Every variable you declare is saved and available in future inputs.
- Functions — Function definitions are kept in a registry so you can call them later.
- Analyzer scope — The semantic analyzer remembers what names exist, so it can catch errors like "undeclared variable" correctly.
Each input goes through the same pipeline as a regular Pebble file:
The difference is that the VM starts each input with the variables from previous successful inputs, and the function registry accumulates across inputs.