The REPL
Running the REPL
Running the Pyro binary without a script argument launches the REPL — an interactive environment where you can run Pyro statements directly, e.g.
>>> echo "hello world"; hello world
Pyro statements normally end with a semicolon, ;
, but you can omit the semicolon after typing a single statement in the REPL, e.g.
>>> echo "hello world" hello world
Hit Ctrl-D
or type exit
and hit return to end the REPL session.
Variables
You can define and use variables in the REPL, just like in a script, e.g.
>>> var value = 123 >>> echo value + 456 579
Expression Statements
As a convenience, if the input statement is an expression that evaluates to any value other than null
, the REPL automatically prints the $debug()
string for the value, e.g.
>>> "foo" + "bar" "foobar"
This is equivalent to running:
>>> echo $debug("foo" + "bar") "foobar"
Multi-line Input
The REPL automatically handles multi-line input, e.g.
>>> "foo ยทยทยท bar" "foo\nbar"
You can define functions and classes over multiple lines, e.g.
>>> def add(a, b) { ยทยทยท return a + b; ยทยทยท } >>> add(1, 2) 3
Line Editing
The REPL supports the standard set of emacs-style line editing commands, e.g. Ctrl-A
to move to the start of the line, Ctrl-E
to move to the end of the line, etc.
You can scroll backwards and forwards through the line-editing history using the up/down arrow keys or, alternatively, Ctrl-P
and Ctrl-N
.