Skip to content

Latest commit

 

History

History
258 lines (175 loc) · 3.03 KB

File metadata and controls

258 lines (175 loc) · 3.03 KB

🧠 Vix REPL — Interactive Runtime Shell

The Vix REPL is an interactive shell built directly into the vix binary. Just like python, node, or deno, you start it simply by typing:

vix

No subcommand. No flags.
This is the default interactive mode of Vix.


✨ What is the Vix REPL?

The Vix REPL is a developer-friendly interactive environment designed to:

  • Experiment with C++-like expressions
  • Test runtime logic quickly
  • Evaluate math expressions
  • Manipulate variables and JSON data
  • Call built-in Vix runtime APIs
  • Prototype logic before moving to real code

It feels familiar if you’ve used:

  • Python REPL
  • Node.js REPL
  • Deno REPL

…but adapted to the Vix.cpp philosophy.


▶️ Starting the REPL

vix

Example startup:

Vix.cpp v1.x (CLI) — Modern C++ backend runtime
[GCC 13.3.0] on linux
Exit: Ctrl+C / Ctrl+D | Clear: Ctrl+L | Type help for help
vix>

🧮 Math Expressions

You can type expressions directly:

1 + 2
10 * (3 + 4)

With variables:

x = 3
x + 1
x * 10

📦 Variables

Assign values

x = 42
name = "Gaspard"

Print variables

x
name

🧩 JSON Support

The REPL supports strict JSON using nlohmann::json.

Objects

user = {"name":"Gaspard","age":10}
user

Arrays

nums = [1,2,3,4]
nums

Nested data

profile = {
  "name":"Gaspard",
  "meta":{"country":"UG","verified":true},
  "tags":["cpp","vix","repl"]
}
profile

⚠️ JSON must be valid
{ "name", "Gaspard" }
{ "name": "Gaspard" }


🖨️ print / println

Basic output

print("Hello")
println("Hello world")

Mix strings and expressions

x = 3
println("x =", x)
println("x+1 =", x+1)

⚙️ Built-in Vix API

The REPL exposes a built-in Vix object.

Working directory

cwd()
Vix.cwd()

Change directory

Vix.cd("..")

Process info

pid()
Vix.pid()

Environment variables

Vix.env("HOME")
Vix.env("PATH")

Arguments

Vix.args()

🛠️ Filesystem helpers

Vix.mkdir("tmp")
Vix.mkdir("tmp/logs", true)

▶️ Running CLI commands

You can run CLI commands from inside the REPL:

Vix.run("version")
Vix.run("help")
Vix.run("check", "--help")

🧹 Session control

Clear screen

clear

or:

Ctrl + L

Exit REPL

exit

or:

Ctrl + D
Ctrl + C

🧠 Tips & Best Practices

  • Use the REPL to prototype logic
  • Validate math & JSON before writing C++
  • Use println() for debugging expressions
  • Treat the REPL as your scratchpad

🧭 Roadmap (REPL)

Planned features:

  • Property access: user.name
  • Function definitions
  • History persistence
  • Autocomplete for variables
  • Structured error hints
  • Module imports

🧾 License

MIT License © Gaspard Kirira
Part of the Vix.cpp ecosystem