The Mech Read-Eval-Print Loop (REPL) provides an interactive environment for executing Mech commands, inspecting symbols, and debugging programs. Below are the available REPL commands.
To start the REPL, run:
mech
You can load a script into the REPL by running with the --repl
option:
mech --repl my_script.mec
Once inside, you can enter commands prefixed with :
, otherwise the REPL will interpret the input as a Mech expression and evaluate it, and print the result and the associated type.
Displays this help message with a list of available commands.
:help
Exits the REPL.
:quit
Searches for symbols in the current session. You can provide an optional search pattern to filter results.
:s :s velocity
Displays the execution plan.
:plan
Searches the symbol directory. Optionally, provide a search pattern to filter results.
:whos :whos position
Clears the screen, resets the cursor position.
:clc
Clears the interpreter state. If a target variable is provided, only that variable is cleared.
:clear :clear x
Loads and executes the supplied a Mech file(s) into the session.
:load my_script.mec :load my_script.mec my_other_script.mec :load my_directory
Lists contents of working directory. Optionally, provide a target path.
>: :ls >: :ls /my/directory
Changes the current working directory.
>: :cd /my/directory
Iterates the execution plan by the specified number of steps. If N is not provided, defaults to 1 step.
>: ~x := 10 >: x += 1 >: :step 10 >: x == 21 -- true