Using the Mech REPL
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.
Starting the REPL
To start the REPL, run:
mech
You can load a script into the REPL by running with the --repl option:
mech my_script.mec --repl
Once inside, you can enter commands prefixed with :, otherwise the REPL will interpret the input as a Mech expression, evaluate it, and print the result with the associated type.
Commands
:cd PATH
Changes the current working directory.
:cd /my/directory
:clc (:c)
Clears the screen, resets the cursor position.
:clc
:clear
Clears the interpreter state. If a target variable is provided, only that variable is cleared.
:clear :clear x
:docs [NAME] (:d)
Displays documentation for the specified name.
:docs install :docs math/sin
:help (:h)
Displays this help message with a list of available commands.
:help
:load
Loads and executes the supplied Mech file(s) into the session.
:load my_script.mec :load my_script.mec my_other_script.mec :load my_directory
:ls [PATH]
Lists contents of working directory. Optionally, provide a target path.
:ls :ls /my/directory
:plan (:p)
Displays the execution plan.
:plan
:quit (:q)
Exits the REPL.
:quit
:step [N]
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
:symbols (:s)
Searches for symbols in the current session. You can provide an optional search pattern to filter results.
:s :s velocity
:whos (:w)
Searches the symbol directory. Optionally, provide a search pattern to filter results.
:whos :whos position