(...ArgsT) -> ReturnT.
First-class functions
Pass a function as a callback: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:a and b are inferred as int from the invokeMath declaration. When parameter types cannot be inferred, they must be specified:
Closures (lambdas with captures)
Lambdas capture outer variables, becoming first-class closures:use or [&] syntax — capturing happens automatically. Variables are captured by value at the point where the lambda is created, so later mutations of the outer variable do not propagate into the closure:
Low-level TVM continuations
Continuations are executable cells representing TVM bitcode. A callable is a typedcontinuation.
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 TVMCONT. Callable values cannot be serialized.