stone¶
stone is a small, statically checked language with Python-like syntax. One binary both interprets a program and compiles it to a native x86-64 or arm64 executable, and the two always agree on what a program prints.
fn fib(n: int) -> int:
if n < 2:
ret n
ret fib(n - 1) + fib(n - 2)
for i in range(10):
print(fib(i))
stone run fib.stn # interpret it right away
stone build fib.stn && ./build/fib # or compile it to a native executable
Why stone¶
Simple to write, fast and safe to run. stone aims for Python’s simplicity with Rust’s
speed, memory safety, and error messages, by moving the complexity into the compiler: you
write types only in function signatures, and no lifetimes or lazy keywords, because the
compiler works out the rest. See Philosophy.
Two backends, one behavior. stone run walks the syntax tree, and stone build lowers it
to an IR, allocates registers, and emits assembly. Every program in the test suite, including
every example in this documentation, runs through both and must print the same thing, down to
float formatting and runtime error messages.
Errors before running. A type checker infers every type, so 1 + "a", mixing ints and
floats, or reading a variable that might not be assigned yet is reported with its line and
column before anything runs.
Editor support. The stone-lsp language server, packaged as a VS Code extension, shows
errors as you type, inferred types on hover, go to definition, references, rename, and
completion.
Getting started
Reference
- Syntax
- Modules
- stone.toml
- Types
- Builtins
- Error codes
- E0001: the program does not parse
- E0002: a character or literal that is not valid
- E0003: a name that is not defined, or not that kind of name
- E0004: no such method, field, variant, or function
- E0005: mismatched types
- E0006: the wrong number of arguments or types
- E0007: a parameter without a type
- E0008: a value that does not fit the return type
- E0009: a call that returns no value used as a value
- E0010: a variable that might be used before it is assigned
- E0011: a value of the wrong kind for an operation
- E0012: a condition that is not a bool
- E0013: values that cannot be compared with
== - E0014: values that cannot be ordered
- E0015: a map key or set element of a type that cannot be one
- E0016: a change to a value that cannot change
- E0017: a change to a variable a function does not own
- E0018: a value changed and used in the same statement
- E0019: an assignment to something that is not a variable or a place
- E0020: a tuple used as something it is not
- E0021: a name defined twice
- E0022: a name that belongs to stone
- E0023: a statement or expression where it is not allowed
- E0024: a name used as a value that is not one
- E0025: something called the wrong way
- E0026: a struct or variant made with the wrong values
- E0027: a
matchthat does not cover every value - E0028: a pattern that does not fit
- E0029: a type that would never end
- E0030: a type parameter used where it cannot be
- E0031: a type that does not implement a trait it needs
- E0032: an impl block that leaves out a trait’s methods
- E0033: a method that does not match its trait
- E0034: an impl block that is not allowed
- E0035: a call that could mean more than one function
- E0036: a value whose type must be known first
- E0037: a conversion that does not exist
- E0038:
?where it cannot return - E0039: a value that holds too many values
- E0040:
selforSelfwhere it does not belong - E0041: a test that reads a global
- E0042:
inchained with another comparison - E0043: a format spec that does not fit its value
- E0044: a module that does not exist
- E0045: a name that is private to its module
- E0046: a feature the target does not support yet
- E0047: a mistake in
stone.tomlorstone.lock - E0048: a dependency that cannot be used
- E0049: a value that cannot be a trait value
- E0050: a constant that is not one
- Lints
- Levels
- W0001: a name that is never used
- W0002: an import that is never used
- W0003: a list literal multiplied by an int
- W0004: a change to a parameter that is lost
- W0005: a case that never runs
- W0006: code that never runs
- W0007: a result that is never used
- W0008: an expression whose value is never used
- W0009: a conversion to the type a value already has
- W0010: a bool compared with true or false
- W0011: a value compared with itself
- W0012: a variable or place assigned to itself
- W0013: a key given twice in a literal
- W0014: a condition tested twice in one chain
- W0015: an operation that fails whenever it runs
- Runtime errors
- Command line
- Projects and their entry file
stone init [PATH] [--lib] [--name NAME] [--no-git]stone run [--offline] [FILE] [-- ARGS...]stone build [FILE...] [-o OUTPUT] [--target TARGET]... [--no-gpu] [--windows-gui] [--offline]stone clean [PATH]stone check [--offline] [FILE] [--deny warnings]stone explain CODEstone test [PATH...] [--build] [--filter TEXT] [-j N] [--offline]stone add PACKAGE [--name NAME] [--host HOST]stone remove NAMEstone fetch [PATH] [--locked]stone tree [PATH]stone fmt [PATH...] [--check]stone update [--check] [--version TAG]stone uninstall [--yes]- Other options
- Editor support