Stoffel-Lang App Programming
Scope: AI-agent-agnostic playbook for building applications with the Stoffel framework. This is not a maintainer guide for compiler, VM, protocol, or release engineering work. Dependency assumption: use the public 0.1.0 install snippets from these docs. When developing against a local checkout, make that source-based workflow explicit.
Use when
Use this playbook when writing.stfl application logic or checking which language features are currently supported by examples and tests.
Current source of truth
crates/stoffel-lang/README.mdcrates/stoffel-lang/examples/README.mdcrates/stoffel-lang/examples/COVERAGE.mdcrates/stoffel-lang/examples/**/*.stflcrates/stoffel-lang/src/builtin_registry.rs
Minimal clear app
Supported app-language surfaces
Current examples cover:- Pythonic indentation,
#comments,deffunctions, typed and inferred returns, explicitreturn,discard, andpass. mainentry points plus no-argument test functions run bystoffel test.- Imports and import aliases.
- Type aliases and scalar names: signed/unsigned 8/16/32/64-bit integers,
bool,float/float64,fix32/fix64, strings, bytes aliases,None. - Integer literal widths/suffixes and hex literals.
- Lists, dictionaries, nested generics, indexing, negative indexing, assignment through index, and slicing where covered by examples.
- Dynamic objects, runtime field access, object schemas, base object syntax, and secret-typed fields.
if/elif/else,while, andforover ranges, lists, and strings.- End-exclusive ranges such as
0..10. - Unary
-,not, arithmetic, comparison, boolean operators, and compound assignment (+=,-=,*=,/=,%=). modfor floored modulo and%for truncating remainder in number-theory examples.- Bitwise keywords on integers:
and,or,xor,not,shl,shr. - Fixed-point arithmetic and comparisons with tolerance checks.
- Field-access method syntax and object builtin syntax.
- Closures exposed by the language stdlib.
- Secret-share arithmetic,
secret boolgates, and client-provided private inputs viaClientStore.
Unsupported or not runtime-ready today
Do not present these as supported app syntax until examples/tests prove otherwise:enumbreakcontinueyieldtry/catch
Builtins to know
Core app builtins:printtypeappend/pushlenslicecontains/inassertLocalStorage.store,LocalStorage.load,LocalStorage.retrieve,LocalStorage.delete,LocalStorage.existsLocalStorage.load_sharefor share-bearing stored values in advanced MPC examples- closure helpers such as
create_closure,create_closure_with_upvalue,call_closure,call_closure_with_arg,get_upvalue,set_upvalue
secret, Share.*, ClientStore.*, Mpc.*, MpcOutput.*, Crypto.*, Bytes.*, Rbc.*, Aba.*, or Avss.*.
Example map
Start with small local examples:local_control_flow: loops, ranges, branching, arithmetic.local_collections: list literals, indexing, append/push/len aliases.local_nested_generics: generic functions over nested list shapes.local_storage: local VM storage.local_dynamic_workflow: dynamic objects, runtime type inspection, callbacks.local_closure_counter: captured upvalues and stateful callbacks.local_text_processing: string iteration.local_uint64_inverse: overflow-safe unsigned modular inverse arithmetic.language_policy_engine: imports, numeric widths, boolean logic, compound assignment.language_mpc_schemas: object schemas with secret-typed fields.
bits/clear/*: popcount, bit reversal, parity, rotations, Gray code, flags, xorshift, etc.matrix/clear/*: multiply, transpose, determinant, Fibonacci powers, Gaussian elimination, convolution, Markov power iteration, graph paths.polynomials/clear/*: Horner evaluation, polynomial multiplication/division, calculus, interpolation, Newton/Chebyshev/Taylor examples.number_theory/clear/*: Euclid, extended Euclid, modular inverse/CRT, LCM, modular exponentiation.
Validation / done criteria
For an app source change:Common pitfalls
- Do not invent syntax from Rust, Python, or JavaScript without checking examples.
- Keep app examples small and runnable.
- Do not use unsupported control-flow constructs (
break,continue) in developer-facing examples. - For secret examples, copy the
# run-args:header and preserve client-slot ordering. - If a program uses secret values or
ClientStore, switch to Stoffel Secret MPC Programming.