Marslang language and API reference#
This reference describes the Rust interpreter as of rs-0.9.0,
including dynamic numeric type tracking and the expanded std.math package.
The source extension is .mars; earlier releases used .mrs.
Use the matching source checkout for the filenames documented here.
These API documents and release notes are eligible for Git tracking. Discussion
notes elsewhere under docs/ remain local.
Reference#
- Language syntax: variables, functions, families, and control flow.
- Strings and slicing: Unicode characters, reversal, and strict bounds.
- Collections: arrays, sets, pairs, maps, and copying.
- Built-ins and errors: input/output, conversions, and runtime errors.
- std.math: 51 math functions and six constants, written in Marslang on native float primitives.
- std.containers: stack, queue, deque, and priority queue.
- std.strings: splitting, searching, trimming, case, and padding.
- std.types: a value's kind, family checks.
- std.time: clocks and sleeping.
- std.Decorator:
@Decorator.privateand@Decorator.subclassmethods.
Install#
Released builds need no Rust toolchain and install into your home directory:
irm https://marslang.kevin-z.com/install.ps1 | iex
curl -fsSL https://marslang.kevin-z.com/install.sh | sh
Both accept --use std,ext (-Use in PowerShell) for the package sets to
install; std is built into the interpreter, and ext is not published yet.
marslang pkgs prints where packages you install are imported from.
Run#
From an installed interpreter, or with Rust from the repository root:
marslang docs/api/examples/strings.mars
cargo run -- docs/api/examples/strings.mars
The runnable example prints:
CDE
EDCBA
ABCDE
3
eฬ๐จโ๐ฉโ๐งโ๐ฆ
0
Use cargo test to run the execution tests, which run programs in the interpreter
and check their output. The example above is also an execution test.
Current limits#
Programs run in a Rust tree-walking interpreter. The language is not self-hosted yet.
Additional standard-library packages, the remaining decorators (static, class,
overload), match, and async remain unimplemented. General named arguments
are deferred; only slicing accepts reverse=. Proposed packages are not APIs.
The lex command uses a separate lexer from the parser. The REPL reruns its
accumulated source rather than retaining a persistent runtime; it shows only new output.