Skip to main content

Reserved keywords

FunC reserves the following symbols and words. These cannot be used as identifiers.

Symbols

+-*/ %?:, ;()[ ]{}= _<>& |^~== !=<=>=<=> <<>>~>>^>> ~/^/~%^% /%+=-=*= /=~/=^/=%= ~%=^%=<<=>>= ~>>=^>>=&=|= ^=->

Words

returnvarrepeatdo whileuntiltrycatch ififnotthenelse elseifelseifnotintcell slicebuilderconttuple typeforallexternglobal asmimpureinlineinline_ref auto_applymethod_idoperatorinfix infixlinfixrconst#pragma #include

Built-ins

This section covers extra language constructs that are not part of the core but are still important for functionality. Although they could be implemented in stdlib.fc, keeping them as built-in features allows the FunC optimizer to work more efficiently. In addition, FunC does not allow the built-in names in this section to be used as identifiers. However, there is an exception: built-ins with non-symbolic names can be used as identifiers for local variables.

Built-ins with symbolic names

_+__-_-__*_ _/__~/__^/__%_ _~%__^%__/%__<<_ _>>__~>>__^>>__&_ _|__^_~_^_+=_ ^_-=_^_*=_^_/=_^_~/=_ ^_^/=_^_%=_^_~%=_^_^%=_ ^_<<=_^_>>=_^_~>>=_^_^>>=_ ^_&=_^_|=_^_^=__==_ _!=__<__>__<=_ _>=__<=>_

Built-ins with non-symbolic names

divmod~divmodmoddiv~moddiv muldivmuldivrmuldivcmuldivmod truefalsenilNil null?throwthrow_ifthrow_unless throw_argthrow_arg_ifthrow_arg_unlessload_int load_uintpreload_intpreload_uintstore_int store_uint~store_int~store_uintload_bits preload_bitsint_atcell_atslice_at tuple_atattouch~touch touch2~touch2~dump~strdump run_method0run_method1run_method2run_method3
The description of each of these built-ins must be specified, together with an example of usage.

throw

throw emits an unconditional exception. throw takes only one argument—the error code—since it always triggers an exception.

throw_if

throw_if emits an exception only if the provided condition is true. It receives two arguments: the error code, which defines the exception type, and the condition.

throw_unless

throw_unless emits an exception only if the provided condition is false. It receives two arguments: the error code, which defines the exception type, and the condition.

throw_arg

throw_arg is an unconditional exception with a parameter. It is the parameterized version of throw. The first argument is a parameter of any type, the second argument defines the error code, and the third argument is the condition.

throw_arg_if

Parameterized version of throw_if. The first argument is a parameter of any type, the second argument defines the error code, and the third argument is the condition.

throw_arg_unless

Parameterized version of throw_unless. The first argument is a parameter of any type, the second argument defines the error code, and the third argument is the condition.

~dump

~dump outputs a variable to the debug log.

~strdump

~strdump outputs a string to the debug log.

divmod

divmod takes two numbers as input and returns the quotient and remainder of their division.

muldiv

muldiv performs a multiply-then-divide operation. It uses a 513-bit intermediate result to prevent overflow if the final result fits within 257 bits.

true

true is an alias for -1.

false

false is an alias for 0.

null?

null? checks if the given argument is null. In FunC, the value null belongs to the TVM type Null, which represents the absence of a value for certain atomic types. See null values for details.

touch and ~touch

touch pushes a variable to the top of the stack. ~touch is identical to touch, but it is adapted for use in modifying syntax.
Link for modifying syntax is missing.

at

Function at returns the value of a tuple element at the specified position.
I