MODULES
Victoria Module System
Victoria uses a simple and powerful module system that supports both built-in modules and user-defined libraries.
Using Modules
Use the include statement to load modules:
victoria
include "os"
include "path"
include "mylib"- Built-in Modules:
os,net,std,math,json,time,path. - User Modules: Victoria looks for
.vcfiles in:- The current directory.
- The
victoria_modules/directory. ~/.victoria/modules/(Global).
When a user module is included, it is evaluated in an isolated environment. All top-level variables and functions are exported as a Hash object named after the module.
Example mylib.vc:
victoria
let version = "1.0.0"
let add = define(a: int, b: int) -> int { return a + b }Example usage:
victoria
include "mylib"
print(mylib.version)
print(mylib.add(1, 2))Package Manager (vic)
Victoria comes with a package manager called vic.
Commands
vic init: Initialize a new project with avic.jsonfile.vic install <user>/<repo>: Install a package from GitHub intovictoria_modules/.vic list: List all installed packages.
Creating and Publishing a Library
- Create a new GitHub repository.
- Add your Victoria code. Use
index.vcormain.vcas the entry point. - Push your code to GitHub.
- Others can now install your library using:
bash
vic install your-username/your-repo-name
Example Library Structure
victoria
your-repo/
├── index.vc (Entry point)
├── utils.vc
└── README.md