-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Jiowcl edited this page Jul 21, 2026
·
18 revisions
| Category | Support |
|---|---|
| Conditional |
if / elseif / else / end
|
| Logic |
and, or, not
|
| Comparison |
==, ~=, <, <=, >, >=
|
| Operation |
+, -, *, /, .., ++, --
|
| Loop |
while, for i = a, b do, for v in list do, for i, v in ipairs(t) do, repeat … until
|
| Type |
number, string, table, boolean, nil, func
|
| Variable |
local, global
|
| Function |
func name(args), local func
|
| Built-in |
print, math.*, string.*, require
|
| OOP |
obj:method() (with self as the first argument) |
| GC | Mark-and-sweep (can be triggered from the VM) |
| Execution | Reads and executes *.vyrn or *.lua scripts |
| Errors |
file:line number:message format |
| Standard Library |
print, readline, math.*, string.*, table.*, io.*, require
|
| Project | Description |
|---|---|
--strict inference |
Region variable type, arithmetic/comparison/concatenation operations compile-time inference |
file type alias |
let f: file = io.open(...) (equivalent to table) |
io.open return value |
File object table (_handle + :read etc. methods) |
| Project | Description |
|---|---|
| GC Root Set | Marks active frame locals, open upvalue slots, and closed upvalue tables |
--strict / Header strict
|
Compile-time type checking for literals let/const, parameter presets, and return
|
| Project | Description |
|------|------| | Dynamic VM stack | Initial 4096 slots, ReDim (+1024) if insufficient | | Dynamic globals | Compiler/VM global table initial 512, grows by +128 as needed | | Dynamic locals | Per-function locale variable table initial 256, grows by +64 as needed |
| Project | Description |
|---|---|
[doc: "..."] |
Pre-class attributes of def / struct; --dump display |
import * as M |
Namespace import (dialect ≥ 11) |
import { a as b } |
Import alias |
| Struct type alias |
def f(p: Vec2) Runtime check table (dialect ≥ 11) |
| Eval |
repl_import_named, repl_import_star
|
| Project | Description |
|---|---|
| Named import |
import { a, b } from "path" (dialect ≥ 10) |
| Project | Description |
|---|---|
| Struct Field Error | Message contains field 'name'
|
| Optional Field |
y: number = 0 (dialect ≥ 10) |
| Struct Method |
def length(self) + v:length() (dialect ≥ 10) |
enum |
Table constant with name → 0,1,2… (dialect ≥ 10) |
| Project | Description |
|---|---|
-- Annotation |
Correction: When the previous line ends with a variable, the -- in the next line will no longer be misinterpreted as a minus sign. |
| Multidimensional Table | Multi-level index assignment such as matrix[i][j] = v
|
global |
Supports errors like global a, b; global C0global C9 will result in a compile error. |
| Metadata Annotations | v1.2 [doc], v1.3 @doc / [deprecated] / field doc (see VyrnSpec) |
| Project | Description |
|---|---|
| Eval Test |
repl_struct, repl_import, repl_tuple_let
|
| Features | Description |
|---|---|
struct |
Field type + constructor; Vec2 { x = 1, y = 2 }
|
import |
import m from "lib.mod" sugar; script binding is local |
f { ... } |
Lua-style table literal calling |
| Function | Description |
|---|---|
| Tuple let | let (a, b): (number, string) = pair() |
parameter #N |
Parameter type error message |
| Functionality | Description |
|---|---|
| Tuple Return Type |
def f() -> (number, number) — bracket sugar, equivalent to -> number, number
|
binding #N Error |
Indicates the binding number when destructuring assignment type mismatch |
function() of .vyrn
|
dialect < 8 still works. function() anonymous; def() anonymous still requires dialect ≥ 8 |
| Functionality | Description |
|---|---|
| Destructuring Assignment Type |
let a: number, b: number = pair() — Runtime check of left-hand side item by item |
table.find_index |
Alias of table.index_of
|
| Functionality | Description |
|---|---|
| Multiple Return Types |
def f() -> number, number; Runtime check on return item by item |
table.index_of(t, v) |
Linear search of array segments, returns a 1-based index or nil
|
string.split(s, d, limit) |
Optional third parameter limits the number of segments (remaining segments are merged into the last segment) |
| Features | Description |
|---|---|
| Multi-level upvalue | Nested def can retrieve outer/outer let (encFrame resolves correctly) |
table.reduce(t, init, f) |
Accumulator folding: f(acc, k, v)
|
table.find(t, f) |
Returns the first matching k, v, otherwise nil
|
Eval while
|
--eval-file supports while … do … end multi-line blocks |
| Features | Description |
|---|---|
| Shared Closure Upvalue | Multiple closures can share storage cells when retrieving the same outer let (on_tick / on_report can read and write the same state) |
| Column Assignment Upvalue |
t.x = … can correctly update the outer table within the closure |
table.map / table.filter
|
Higher-order iteration: map returns a new array, filter returns the filtered table |
Eval for / while
|
Fixed ReplSourceComplete, --eval-file can now use for … do … end
|
| Function | Description |
|---|---|
table.foreach(t, f) |
Calls f(k, v) for each key-value pair; if f returns a non-nil, it stops and returns the value. |
table.sort Stability |
Bubble sort implementation; equal elements maintain their original relative order. |
| Function | Description |
|---|---|
math.randomseed(n) |
Resets the PRNG (aligns with PureBasic RandomSeed) |
ipairs(t) / pairs(t)
|
Can be used as a first-class function; returns iter, state, var (manual iteration) |
| Functionality | Description |
|---|---|
local function f() recursion + upvalue |
Self-referenced prologue and OP_CLOSURE integration |
assert(v [, msg]) |
Throws an error on failure (can be caught by pcall); returns v on success |
| Functionality | Description |
|---|---|
pcall(f, ...) |
Protected call; returns true, result on success, false, message on failure |
error(msg) |
Throws an error (can be caught by pcall) |
| Syntax | Description |
|---|---|
def(x) ... end |
Anonymous function expression (requires -- vyrn: 8) |
function(x) ... end |
Anonymous function (.lua or -- vyrn: 8) |
table.sort(t, cmp) |
Custom comparison function (def(a,b) is available for dialects ≥ 8) |
| Syntax | Explanation |
|---|---|
Nested def / local func
|
Inner function is readable and writable, outer let / local (closure upvalue) |
| Syntax | Description |
|---|---|
REPL ...> Continuation |
Multi-line match / def / Block input |
def f(x, y = outer + 1) |
Expression default parameters (evaluated on each call) |
| Syntax | Description |
|---|---|
def f(x, y = 10) |
Preset arguments (literal or expression; requires -- vyrn: 5) |
| Syntax | Description |
|---|---|
"Hello, {name}!" |
Double-quoted string interpolation (requires -- vyrn: 4; \{ \} escape) |
match x / pat => stmt / else => / end
|
Literal pattern matching (desugar is if/elif) |
| Syntax | Description |
|---|---|
continue |
Jump to the next loop (while / for / repeat) |
const x: number = 1 |
A region constant that cannot be reassigned (compile-time check) |
REPL / -e supports typed let (runtime type checking) and global const (cannot be reassigned). --eval-file executes a multi-line eval from a file.
| Syntax | Explanation |
|---|---|
let x: number = 1 |
Locale variable type annotation (runtime check during assignment) |
let a: number, b: string = 1, "x" |
Multivariable + type annotation |
| Features | Examples | Descriptions |
|---|---|---|
# Length |
#"hi"、#{1,2,3}
|
-- |
table.sort |
table.sort(nums) |
In-place sorting; stable (equal elements are not transposed) |
table.foreach |
table.foreach(t, f) |
Iterates through key-value pairs; f returns a non-nil value, ending early |
table.map |
table.map(t, f) |
Returns a new array (each f(k,v) result) |
table.filter |
table.filter(t, f) |
Returns a new table after filtering |
table.reduce |
table.reduce(t, init, f) |
Folds f(acc, k, v)
|
table.index_of |
table.index_of(t, v) |
Searches for values in an array segment, returning the index |
| Multiple return values |
return a, b, let x, y = f()
|
-- |