Skip to main content
Tolk supports first-class functions. Function values have callable types of the form (...ArgsT) -> ReturnT.

First-class functions

Pass a function as a callback:
A function myPlus has the type (int, int) -> int. A function demo, for example, has the type () -> void. Functions can be assigned to variables:

Lambda functions

Tolk supports lambda functions:
Lambda parameter types may be omitted when they can be inferred. In the example above, both a and b are inferred as int from the invokeMath declaration. When parameter types cannot be inferred, they must be specified:
As first-class functions, lambdas can also be returned:
Lambdas are primarily used in general-purpose tooling. They can be combined with generic types and used as nested expressions without restrictions.
Lambdas are not closures. Capturing variables from an outer scope is not supported:

Low-level TVM continuations

Continuations are executable cells representing TVM bitcode. A callable is a typed continuation. Tolk provides the low-level type continuation. For example, the TVM register c3 contains the smart contract code. Some functions are available in the standard library:

Stack layout and serialization

A callable is backed by the TVM CONT. Callable values cannot be serialized.