Functions and their types
This content is not available in your language yet.
Functions in Tact could be defined in different ways:
- Global static function
- Extension functions
- Mutable functions
- Native functions
- Receiver functions
- Getter functions
All functions, except for receiver functions can have a trailing comma in their definitions (parameter lists) and calls (argument lists):
Global static functions
You can define global function anywhere in your program:
Virtual and abstract functions
You can allow the contract inheriting a traits to modify an internal function, if it has the virtual
keyword, using override
. The function can be also marked as abstract
, in which case the inheriting contract has to define its implementation:
Extension function
Extension functions allow you to implement extensions for any possible type.
Warning The name of the first argument MUST be named
self
and the type of this argument is the type you are extending.
Mutable functions
Mutable functions are performing mutation of a value replacing it with an execution result. To perform mutation, the function must change the self
value.
Native functions
Native functions are direct bindings of FunC functions:
Note Native functions could be also mutable and extension ones.
Receiver functions
Receiver functions are special functions that are responsible for receiving messages in contracts and could be defined only within a contract or trait.
Getter Functions
Getter functions define getters on smart contracts and can be defined only within a contract or trait.