Declarations
fundeclares a function.get fundeclares a get method.vardeclares a variable.valdeclares an immutable variable.
inline_ref are written as @ attributes.
Syntax and semantics
- No
impure. All functions are treated asimpureby default; the compiler does not remove user function calls. - Use
onInternalMessage,onExternalMessage, andonBouncedMessageinstead ofrecv_internalandrecv_external. 2+2is 4, not an identifier. Identifiers are alphanumeric. Useconst OP_INCREASEinstead ofconst op::increase.cellandsliceare valid identifiers; not keywords.- Logical operators AND
&&, OR||, NOT!are supported.
Syntax improvements
;; comment→// comment{- comment -}→/* comment */#include→import; strict rule: import only what is used~ found→!found; used for boolean values only (true is -1, as in FunC)v = null()→v = nullnull?(v)→v == null, similar forbuilder_null?and others~ null?(v)→c != nullthrow(excNo)→throw excNocatch(_, _)→catchcatch(_, excNo)→catch(excNo)throw_unless(excNo, cond)→assert(cond, excNo)throw_if(excNo, cond)→assert(!cond, excNo)return ()→returndo ... until (cond)→do ... while (!cond)elseif→else ififnot (cond)→if (!cond)"..."c→stringCrc32("...")and other postfixes
Compilation model
- Functions can be called before declaration.
- Forward declarations are not required.
- The compiler first parses and then resolves symbols, producing an AST representation of the source code.
Standard library
- Standard library functions use clear, camelCase names.
- The stdlib is embedded and split into multiple files.
- Common functions are available; specialized ones can be imported. For example,
import "@stdlib/tvm-dicts". - IDEs provide import suggestions.
- See the FunC-Tolk stdlib mapping.
Language features
- No
~tilde methods. See mutability details. - Type mismatch errors are clear and readable.
- The
booltype is supported. - Indexed access
tensorVar.0andtupleVar.0is supported. - Nullable types
T?, null safety, smart casts, and the operator!are supported. - Union types and pattern matching are supported for types and expressions, with switch-like behavior.
- Type aliases are supported.
- Structures are supported.
- Generics are supported.
- Methods as extension functions are supported.
- Enums are supported.
- Trailing comma is supported.
- A semicolon after the last statement in a block is optional.
- Fift output contains original
.tolklines as comments. - Auto-packing to and from cells is supported for all types.
- Universal createMessage simplifies cell composition.
map<K, V>instead of low-level TVM dictionaries.- The compiler automatically detects and inlines functions.
- Includes gas optimization improvements.
Tooling around
- JetBrains IDE plugin
- VS Code extension
- FunC-to-Tolk converter
- tolk-js WASM wrapper for blueprint