Vix Reply
Interactive REPL engine for Vix.
Vix Reply powers the vix and vix repl interactive experience. It provides a fast shell for testing expressions, variables, JSON values, runtime helpers, and real C++ snippets powered by the Vix run pipeline.
Start the REPL
Running vix without a command starts the REPL by default:
vixYou can also start it explicitly:
vix replTo pass arguments into the REPL session, use --:
vix repl -- --port 8080 --mode devInside the REPL, those arguments are available with:
Vix.args()Example startup
Vix Reply v2.5.6 REPL
gcc 13.3 linux
exit: Ctrl+D | clear: Ctrl+L | help
>>>What the REPL is for
Use Vix Reply when you want to:
- test small expressions
- evaluate math quickly
- create and inspect variables
- validate JSON values
- inspect environment values
- call simple Vix runtime helpers
- run real C++ snippets from an interactive session
- prototype small ideas before moving them into a C++ file
Vix Reply is inspired by interactive shells from tools like Python, Node.js, and Deno, but adapted to the Vix.cpp workflow.
Basic commands
help
version
pwd
cd <dir>
clear
history
history clear
exitYou can also clear the screen with:
Ctrl+LTo exit, use:
exitor:
Ctrl+DExpressions
You can type expressions directly:
>>> 1 + 2
3
>>> 10 * (3 + 4)
70
>>> 100 / 5
20You can also use calc explicitly:
>>> calc 10 * (2 + 3)
50Variables
Assign a value:
>>> x = 42
42Read it back:
>>> x
42Use it in another expression:
>>> x + 1
43
>>> x * 10
420String values are supported:
>>> name = "Gaspard"
name = "Gaspard"
>>> name
GaspardOther simple values are supported too:
>>> age = 25
age = 25
>>> price = 19.99
price = 19.99
>>> active = true
active = trueJSON values
Vix Reply supports strict JSON values.
Objects
>>> user = {"name":"Gaspard","age":25}
user = {"age":25,"name":"Gaspard"}
>>> user
{"age":25,"name":"Gaspard"}Arrays
>>> nums = [10,20,30]
nums = [10,20,30]
>>> nums
[10,20,30]Nested JSON
>>> profile = {"name":"Gaspard","meta":{"country":"UG","verified":true},"tags":["cpp","vix","reply"]}
profile = {"meta":{"country":"UG","verified":true},"name":"Gaspard","tags":["cpp","vix","reply"]}Access object properties:
>>> user.name
Gaspard
>>> user["name"]
GaspardAccess arrays:
>>> nums[0]
10
>>> profile.tags[1]
vixJSON must be valid.
Wrong:
{"name","Gaspard"}Correct:
{ "name": "Gaspard" }Printing output
Use print():
>>> print("Hello")
HelloUse println():
>>> println("Hello world")
Hello worldYou can mix strings and values:
>>> x = 3
x = 3
>>> println("x =", x)
x = 3
>>> println("x + 1 =", x + 1)
x + 1 = 4Supported examples:
print("hello")
println("hello", "world")
println(42)
println(-42)
println(3.14)
println(true)
println(null)Built-in helpers
Vix Reply exposes simple helpers directly and through the built-in Vix object.
Current working directory
>>> cwd()
/home/user/projector:
>>> Vix.cwd()
/home/user/projectChange directory
>>> Vix.cd("..")Process id
>>> pid()
12345or:
>>> Vix.pid()
12345Environment variables
>>> Vix.env("HOME")
/home/user
>>> Vix.env("PATH")
/usr/local/bin:/usr/bin:/binREPL arguments
>>> Vix.args()
["--port","8080","--mode","dev"]Create directories
>>> Vix.mkdir("tmp")Create nested directories:
>>> Vix.mkdir("tmp/logs", true)Exit with a code
>>> Vix.exit(0)Value helpers
Length
>>> name = "Gaspard"
name = "Gaspard"
>>> len(name)
7>>> nums = [10,20,30]
nums = [10,20,30]
>>> len(nums)
3>>> user = {"name":"Gaspard","age":25}
user = {"age":25,"name":"Gaspard"}
>>> len(user)
2Convert values
>>> int("42")
42
>>> int(42.0)
42
>>> float("3.14")
3.140000
>>> float(10)
10.000000
>>> str(25)
25Inspect types
>>> type(user)
object
>>> type(nums)
array
>>> type(user.name)
string
>>> type(nums[0])
intC++ snippet mode
Vix Reply can run real C++ snippets through the normal Vix run pipeline.
Enter C++ mode:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp>Example:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp> #include <vector>
... #include <vix/print.hpp>
... int main() {
... vix::print("Hello, world", 2, true, std::vector<int>{1,2,3});
... }
Hello, world 2 true [1, 2, 3]Run a Vix HTTP server from the REPL
You can also start a small Vix HTTP server from C++ snippet mode:
>>> :cpp
C++ mode. Type :run to execute or :cancel to exit.
cpp> #include <vix.hpp>
... using namespace vix;
...
... int main() {
... App app;
...
... app.get("/", [](Request&, Response& res) {
... res.send("Hello, world");
... });
...
... app.run(8080);
... }Then test it from another terminal:
curl http://localhost:8080Expected output:
Hello, worldC++ mode commands
:cpp Enter C++ snippet mode
:run Run the current C++ snippet
:cancel Cancel C++ snippet modeImportant note about C++ mode
Vix Reply is not a full C++ interpreter.
C++ snippet mode writes the snippet to a temporary .cpp file and runs it through vix run. This means the code is validated by the real C++ compiler and uses the normal Vix build, diagnostics, and runtime behavior.
The snippet must be valid C++ code.
For example, callbacks must use valid C++ lambda syntax:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
});Common mistakes
Invalid JSON syntax
JSON objects require key: value pairs.
Wrong:
{"name","Gaspard"}Correct:
{ "name": "Gaspard" }Forgetting quotes around strings
Wrong:
>>> name = GaspardCorrect:
>>> name = "Gaspard"Passing REPL arguments without --
Wrong:
vix repl --port 8080Correct:
vix repl -- --port 8080Everything after -- is passed to the REPL session and becomes available through Vix.args().
Forgetting to close a C++ function call
Wrong:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
}Correct:
app.get("/", [](Request&, Response& res) {
res.send("Hello, world");
});Common workflow
Start the REPL:
vixTry simple values:
>>> x = 10
10
>>> x * 2
20Inspect the environment:
>>> Vix.cwd()
/home/user/project
>>> Vix.env("HOME")
/home/userCheck JSON:
>>> user = {"name":"Ada","role":"developer"}
user = {"name":"Ada","role":"developer"}
>>> user.role
developerRun C++:
>>> :cpp
cpp> #include <vix/print.hpp>
... int main() {
... vix::print("Hello from C++");
... }
Hello from C++Exit:
>>> exitBest practices
- Use the REPL as a scratchpad.
- Use it to validate small expressions.
- Use it to inspect environment values.
- Use it to test JSON values before using them in config files or APIs.
- Use C++ snippet mode to quickly test real C++ code through the Vix pipeline.
- Move larger code into a real
.cppfile or project once the idea is validated.
Module layout
include/vix/reply/
api/
console/
core/
src/
api/
console/
core/Public entry point
The main entry point is:
#include <vix/reply/core/ReplFlow.hpp>
int repl_flow_run(const std::vector<std::string>& replArgs);The Vix CLI uses this entry point to implement:
vix replNext step
Continue with project creation.