vx (V Executor)
vx is an interpreter for the V programming language.
vx source code is AGPL-licensed and published on GitHub.
vx OPTIONS hello-world.vx vx OPTIONS -e 'print "Hello world"'
In the first form,
vx will attempt to open the file given as the first argument (
hello-world.vx) and execute its contents as V code.
In the second form,
vx will execute the parameter to the
-e option (
print "Hello world") as V code.
In either form, any subsequent arguments will be stored in
-Z option indicates "zero restrictions", and should only be specified for programs that the user trusts not to cause harm.
These facilities are not part of V proper because they interact with the host environment.
argvis an array of strings, consisting of either the program pathname or
"-e", followed by the remaining arguments (following either the program pathname or inline source, respectively).
eval(string) => ...is a sandboxed eval() function. It parses the string as V code and executes it. Only the keyword symbol table is visible — everything else, including impure functions, all local and global program state, and eval() itself, are unavailable to the sandboxed code. If a parsing error, run-time error, or uncaught exception occurs, an exception is thrown. Otherwise, the result of executing the parsed code is returned.
getenv(string) => string|()works like its C counterpart, returning the value of the named environment variable. If the variable is not set in the environment, it returns
(), the empty list.
load(string) => stringreads the contents of the regular file whose pathname is passed and returns them, or throws an exception on error.
print(...)accepts any list of printable values (including the empty list), concatenates them, appends
'\n', and writes the result to standard output.
system(string|()) => intis a wrapper around C’s
system(). If the
-Zoption wasn’t specified, it can only be called with an empty argument list, and it returns an empty list. If the
-Zoption was specified, then given an empty list it returns
trueif the system shell facility is available or
falseif it isn’t. Given a string with no NUL bytes (and the
-Zoption), it runs the string as a shell command. If the native
system()call returns an error, or the shell’s status indicates that it terminated on a signal or exited with a non-zero status, then an exception is thrown. Otherwise, zero is returned.
time() => intworks like its C counterpart, returning the number of seconds since 1970-01-01.